[R] function input as variable name (deparse/quote/paste) ??

casperyc casperyc at hotmail.co.uk
Sat Mar 10 22:29:16 CET 2012


Hi all

Say I have a function:

myname=function(dat,x=5,y=6){
    res<<-x+y-dat
}

for various input such as

myname(dat1)
myname(dat2)
myname(dat3)
myname(dat4)
myname(dat5)

how should I modify the 'res' line, to have new informative variable name
correspondingly, such as

dat1.res
dat2.res
dat3.res
dat4.res
dat5.res

stored in the workspace.

This is only an example of a complex function I have written.

Thanks in advance!

Casper




--
View this message in context: http://r.789695.n4.nabble.com/function-input-as-variable-name-deparse-quote-paste-tp4462841p4462841.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list