[R] basic information defining functions

From: Bunny, lautloscrew.com <bunny_at_lautloscrew.com>
Date: Tue, 25 Nov 2008 11:17:49 +0100


Hi all,

i am looking from some insights to define own R functions. so far i found most basics in documentations that are around on the web. except for one thing:

IŽd like to define some function, say:

#assume my data matrix contains vectors like data$myColumn1,data $myColumn2 etc.

getMyColumn <- function (columnid){

x<-data$MyColumn?columnid?[data$indexone=1 & data$index2=5]

return(x)

}

Do I need to use assign or eval first ? I tried to use paste to combine something like: paste("data$MyColumn",columnid,sep="") which did not work.

I am happy to get any help with the problem, but also thankful for some useful link or guide on how to define own functions properly, especially the dynamic naming and return part

thx in advance

bunny



R-help_at_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. Received on Tue 25 Nov 2008 - 10:24:24 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 25 Nov 2008 - 17:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive