Hey there,
I've got a for loop in my code which I'm having difficulty seeing how to
avoid.
Here's the code, with some sample data. You can safely copy and paste into
the interpreter if you want.
#I have some data frames.
a <- as.data.frame(matrix(runif(50), nrow = 10, ncol = 5))
b <- as.data.fra
Steve Jaffe wrote:
> I'm trying to build up a list of data.frames by "appending" one by one.
>
> If x,y,z are data.frames, I can do
>
> somelist <- list(x, y, z) (or even somelist <- list(x=x, y=y, z=z) to get
> names)
>
> But if I start with
>
> somelist <- list(x,y) and now want to go from thi
On Jun 17, 2009, at 2:45 PM, Dimitris Rizopoulos wrote:
try this:
dat1 <- data.frame(x = rnorm(5))
dat2 <- data.frame(y = rnorm(5))
dat3 <- data.frame(z = rnorm(5))
lis <- list(dat1 = dat1, dat2 = dat3)
c(lis, list(dat3 = dat3))
Or:
lis[["dat3"]] <- dat3
I hope it helps.
Best,
Dimitr
try this:
dat1 <- data.frame(x = rnorm(5))
dat2 <- data.frame(y = rnorm(5))
dat3 <- data.frame(z = rnorm(5))
lis <- list(dat1 = dat1, dat2 = dat3)
c(lis, list(dat3 = dat3))
I hope it helps.
Best,
Dimitris
Steve Jaffe wrote:
I'm trying to build up a list of data.frames by "appending" one by
I'm trying to build up a list of data.frames by "appending" one by one.
If x,y,z are data.frames, I can do
somelist <- list(x, y, z) (or even somelist <- list(x=x, y=y, z=z) to get
names)
But if I start with
somelist <- list(x,y) and now want to go from this to list(x,y,z) I'm stuck.
I've t
5 matches
Mail list logo