[R] Constructing a list using a function...

Onur Uncu onuruncu at gmail.com
Mon Jul 2 08:02:37 CEST 2012


Hi All

I have a dataframe:

myframe<-data.frame(ID=c("first","second"),x=c(1,2),y=c(3,4))

And I have a function myfun:

myfun<-function(x,y) x+y

I would like to write a function myfun2 that takes myframe and myfun
as parameters and returns a list as below:

mylist
$first
[1] 4

$second
[2] 6

Could you please help me with this? Doesn't seem like the "apply"
family of functions were intended for this case.



More information about the R-help mailing list