Re: [R] Variable passed to function not used in function in select=... in subset

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Mon, 10 Nov 2008 13:28:42 -0200

Try this:

TestFunc<-function(df, group) {

    return(names(eval(bquote(subset(df1, select = .(group)))))) }

On Mon, Nov 10, 2008 at 1:18 PM, Karl Knoblick <karlknoblich_at_yahoo.de>wrote:

> Hello!
>
> I have the problem that in my function the passed variable is not used, but
> the variable name of the dataframe itself - difficult to explain, but an
> easy example:
>
> TestFunc<-function(df, group) {
> print(names(subset(df, select=group)))
> }
> df1<-data.frame(group="G1", visit="V1", value=0.9)
> TestFunc(df1, c("group", "visit"))
>
> Result:
> [1] "group"
>
> But I expected and want to have [1] "group" "visit" as result! Does anybody

> know how to get this result?
>
> Thanks!
> Karl
>
>
>
>
> ______________________________________________
> 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.
>

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]


______________________________________________ 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 Mon 10 Nov 2008 - 15:32:23 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 Mon 10 Nov 2008 - 16:30:23 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