[R] Applying a function to a column of a data frame
Onur Uncu
onuruncu at gmail.com
Sat Jun 9 16:12:17 CEST 2012
Apologees the novice question. Currently climbing up the learning curve of R.
Suppose I have the following function and the data.frame:
testfun<-function(x=1,y=2) x+y
testframe=data.frame(col1=c(1,2),col2=c(3,4))
When evaluating testfun, I want to use the default value for y (which
is 2) and for x, I want to feed (one by one) the values in col2 of
testframe. How can I achieve this please? Not having much success with
apply()
Thanks for any help.
More information about the R-help
mailing list