[R] passing arguments to subset from a function

GOUACHE David D.GOUACHE at arvalisinstitutduvegetal.fr
Wed Dec 17 20:07:08 CET 2008


Hello R-helpers,
 
I'm writing a long function in which I manipulate a certain number of datasets. I want the arguments of said function to allow me to adapt the way I do this. Among other things, I want my function to have an argument which I will pass on to subset() somewhere inside my function. Here is a quick and simplified example with the iris dataset.
 
myfunction<-function(table, extraction)  {
     table2<-subset(table, extraction)
return(table2) }
 
myfunction(iris, extraction= Species=="setosa")
 
 
############## end
 
What I would like is for this function to return exactly the same thing as : 
subset(iris, Species=="setosa")
 
 
Thanks for your help.
 
Regards,
 
David Gouache



More information about the R-help mailing list