[R] Applying forecast functions to columns in a data frame

Bert Gunter gunter.berton at gene.com
Tue Jun 22 17:38:05 CEST 2010



Bert Gunter
Genentech Nonclinical Biostatistics
 
 -----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of phani kishan
Sent: Tuesday, June 22, 2010 8:10 AM
To: David Winsemius
Cc: r-help at 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



More information about the R-help mailing list