Skip to content
Prev 164477 / 398503 Next

call lattice function in a function passing "groups" argument

On Thu, Dec 11, 2008 at 2:55 AM, Thomas Zumbrunn <t.zumbrunn at unibas.ch> wrote:
Yes, that's the price of non-standard evaluation.
The obvious solution is to evaluate 'groupvar' yourself:

f <- function(data, groupvar) {
  groupvar <- eval(substitute(groupvar), data, parent.frame())
  densityplot(~ x, data, groups = groupvar)
}

A more general solution (where 'groupvar' may be missing) is to use
match.call() etc. (e.g., see lattice:::dotplot.formula)

-Deepayan