Skip to content
Prev 245465 / 398503 Next

Passing parameter to a function

Hi Duncan,

Yes, A and B are columns in D. Having said that I and trying to avoid 

tab(D$A,D$B)

and I would prefer:

tab(A,B)

Unfortunately the syntax you suggest is giving me the same error:

Error in eval(expr, envir, enclos) : object "A" not found

I have tried to add some deparse() but I have got the error over again. The last version I have tried:

function(x,y){
    z <- substitute(time ~ x + y, list(x = deparse(substitute(x)), y = deparse(substitute(y))))
    xtabs(z, data=D)

gives me another error:

Error in terms.formula(formula, data = data) : 
  formula models not valid in ExtractVars 

Any idea on how I should modify the function to make it work?

Thanks,
Luca


Il giorno 20/dic/2010, alle ore 19.28, Duncan Murdoch ha scritto: