Hey, Thanks a lot everyone. Taking care of the NA's and setting right the type-casting I could apply lapply. I have read the documentation for R and it is mentioned that statistical and mathematical methods could be applied across data frames but when lapply didn't work (due to the above said errors) I assumed not all functions could be applied. I was also skeptical as to the kind of output that would be given by R as I only wanted the values of the coefficients.
Thanks a lot for clearing it up for me. Regards, Phani On Tue, Jun 22, 2010 at 9:08 PM, Bert Gunter <gunter.ber...@gene.com> wrote: > > > Bert Gunter > Genentech Nonclinical Biostatistics > > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On > Behalf Of phani kishan > Sent: Tuesday, June 22, 2010 8:10 AM > To: David Winsemius > Cc: r-help@r-project.org > Subject: Re: [R] Applying forecast functions to columns in a data frame > > Simple operations like mean etc. can be applied > using lapply but not statistical functions. > > --NONSENSE! > > func <- function(x){ > ##write any function you like > z <- sin(x^2-2)+rnorm(length(x)) > lm(z~ seq(along=z)) > } > dat <- data.frame(a=1:5,b=rnorm(5)) > lapply(dat,func)## could also have been inserted inline > > > Have you read "An Introduction to R" where these sorts of things are > discussed? > > > > > Bert Gunter > Genentech Nonclinical Biostatistics > > -- A. Phani Kishan 3rd Year B.Tech Dept. of Computer Science & Engineering IIT MADRAS Ph: +919962363545 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.