Re: [R] Creating data frame with residuals of a data frame

2011-10-26 Thread jim holtman
try this: > age<- c(5,6,10,14,16,NA,18) > value1<- c(30,70,40,50,NA,NA,NA) > value2<- c(2,4,1,4,4,4,4) > df<- data.frame(age, value1, value2) > > #Run linear regression to adjust for age and get residuals: > > lm_f <- function(x) { + x<- residuals(lm(data=df, formula= x ~ age)) + } > resid <- appl

[R] Creating data frame with residuals of a data frame

2011-10-24 Thread francesca casalino
Dear experts, I am trying to create a data frame from the residuals I get after having applied a linear regression to each column of a data frame, but I don't know how to create this data frame from the resulting list since the list has differing numbers of rows. So for example: age<- c(5,6,10,14