[R] Parameter of a function used after $ in a data frame

2014-08-13 Thread madhvi.gupta
Hi, Can anyone please tell me how to use a argument of a function after $ sign of a data frame.That argument is one of the column name of the data frame. Thanks, Madhvi __ R-help@r-project.org mailing list

Re: [R] Parameter of a function used after $ in a data frame

2014-08-13 Thread Rui Barradas
I don't believe I understand your question, but here it goes. dat - data.frame(x = rnorm(100), y = runif(100)) mean(dat$x) Hope this helps, Rui Barradas Em 13-08-2014 12:33, madhvi.gupta escreveu: Hi, Can anyone please tell me how to use a argument of a function after $ sign of a data

Re: [R] Parameter of a function used after $ in a data frame

2014-08-13 Thread William Dunlap
Use [[ instead of $. E.g., f - function(columnName) { d - data.frame(x=1, y=2, z=3) d[[columnName]] } f(z) # 3 cName - y f(cName) # 2 Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Aug 13, 2014 at 4:33 AM, madhvi.gupta madhvi.gu...@orkash.com wrote: Hi, Can anyone please tell