[R] Using objectname in function

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Aug 18 13:19:18 CEST 2010


On Wed, Aug 18, 2010 at 12:10 PM, JesperHybel <jesperhybel at hotmail.com> wrote:
> f<-function(x,y){ table(x,y

If you look at the code for 'plot', you'll see it does that with some
deparse/substitute magic. Then use the dnn option to table to set the
names:

f<-function(x,y){
table(x,y,dnn=c(deparse(substitute(x)),deparse(substitute(y))))}

Barry



More information about the R-help mailing list