Eval error when using subset argument in dlply #192

Closed
imanuelcostigan opened this Issue Jan 6, 2014 · 2 comments

Comments

Projects
None yet
2 participants

I get the following error:

> library (ggplot2)
> dlply(diamonds, .(clarity), lm, formula = price ~ carat, subset = cut == 'Ideal')
Error in eval(expr, envir, enclos) : 
  ..2 used in an incorrect context, no ... to look in

So I thought maybe I was using the subset argument incorrectly. But

> lm(price~carat, data=diamonds, subset=cut=='Ideal')
Call:
lm(formula = price ~ carat, data = diamonds, subset = cut == 
    "Ideal")

Coefficients:
(Intercept)        carat  
      -2300         8192 

Traceback:

> traceback()
12: eval(expr, envir, enclos)
11: eval(substitute(subset), data, env)
10: model.frame.default(formula = ..1, data = piece, subset = ..2, 
        drop.unused.levels = TRUE)
9: stats::model.frame(formula = ..1, data = piece, subset = ..2, 
       drop.unused.levels = TRUE)
8: eval(expr, envir, enclos)
7: eval(mf, parent.frame())
6: .fun(piece, ...)
5: (function (i) 
   {
     ...
4: .Call("loop_apply", as.integer(n), f, env)
3: loop_apply(n, do.ply)
2: llply(.data = pieces, .fun = .fun, ..., .progress = .progress, 
       .inform = .inform, .parallel = .parallel, .paropts = .paropts)
1: dlply(diamonds, .(clarity), lm, formula = price ~ carat, subset = cut == 
       "Ideal")
Owner

hadley commented Jan 6, 2014

I'm pretty sure that's because lm uses non-standard evaluation poorly:

lapply(split(diamonds, diamonds$clarity), lm, formula = price ~ carat, subset = cut == 'Ideal')

hadley closed this Jan 6, 2014

bummer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment