[R] list of data.frames

2011-07-18 Thread Andrew Winterman
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 -

[R] list of data.frames?

2009-06-17 Thread Steve Jaffe
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 tried

Re: [R] list of data.frames?

2009-06-17 Thread Dimitris Rizopoulos
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 one.

Re: [R] list of data.frames?

2009-06-17 Thread David Winsemius
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, Dimitris

Re: [R] list of data.frames?

2009-06-17 Thread Wacek Kusnierczyk
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 this to