Re: [R] apply a function separately on each element of a list

2012-08-28 Thread jeff6868
Yes, this is it (as would say michael)! Thank you guys! Last question about another function on this list: imagine this list is my data after your function for the regression model: mydf - data.frame(x=c(1:5), y=c(21:25),z=rnorm(1:5)) mylist - rep(list(mydf),5) Don't care about this fake data,

Re: [R] apply a function separately on each element of a list

2012-08-24 Thread Daniel Malter
The easiest way may be to use lmList in the nlme library: #simulate data d-rep(1:10,each=10) x-rnorm(100) e-rnorm(100) y-2*x+e require(nlme) #or install and load package lmList(y~x|d) #predicted values are obtained with: predict(lmList(y~x|d) HTH, Daniel jeff6868 wrote Hi everybody,

[R] apply a function separately on each element of a list

2012-08-24 Thread jeff6868
Hi everybody, I have a question about applying a specific function (with the calculations I want to do), on a list of elements. Each elements are like a data.frame (with nrows and ncolumns), and have the same structure. At frist, I had a big data.frame that I splitted in all my elements of my

Re: [R] apply a function separately on each element of a list

2012-08-24 Thread Rui Barradas
Hello, Your example doesn't run, lmList needs a 'data' argument. set.seed(8109) d - rep(1:10, each=10) x - rnorm(100) e - rnorm(100) y - 2*x + e dat - data.frame(x=x, y=y, d=d, e=e) model - lmList(y ~ x | d, data = dat) predict(model) To the op: if you already have the larger data.farme