Dear R community,

I am struggling a bit with a probably fairly simple task. I need to use some
already existing functions as argument for a new function that I am going to
create. 'dataset' is an argument, and it comprises objects named
'mean_test', 'sd_test', 'kurt_test' and so on. 'arg1' tells what object I
want (mean, sd, kurt) while 'arg2' tells what to do to the object taken in
'arg1' (again could be mean, sd, but also any other operation/function).

I was thinking about something like:

myfunction<-function(dataset,arg1,arg2)

{

attach(dataset)
result=arg2(paste(arg1,"_test"))

return(result)

}

But this of course does not work! 'arg1' is of type closure and I cannot set
it as character. Moreover, paste will create a string, and I do not think I
can pass a string to the function of 'arg2'. How should I do?

Thanks,
Marco
-- 
View this message in context: 
http://r.789695.n4.nabble.com/Pasting-function-arguments-and-strings-tp2993905p2993905.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.

Reply via email to