Message-ID: <200305260450.h4Q4oK6b005043@r.hankin.sges.auckland.ac.nz>
Date: 2003-05-26T04:50:20Z
From: robin hankin
Subject: vectorizing data.frame()
Hello everybody.
I have a dozen or so vectors (of different lengths) which I want to
coalesce into a dataframe, as in the following toy example.
R> foo <- c(1,2,3)
R> bar <- c(7,8)
R> data.frame(name =c(rep("foo",length(foo)),rep("bar",length(bar))),
value=c(foo,bar))
name value
1 foo 1
2 foo 2
3 foo 3
4 bar 7
5 bar 8
Is there a better (vectorized) way?
--
Robin Hankin, Lecturer,
School of Geography and Environmental Science
Tamaki Campus
Private Bag 92019 Auckland
New Zealand
r.hankin_AT_auckland.ac.nz
tel 0064-9-373-7599 x6820; FAX 0064-9-373-7042