lith
2010-Feb-16 14:18 UTC
[R] ellipsis-related error: used in an incorrect context, no ... to look in
Hi, I have the following code snippet: require(lattice) f.barchart <- function(...) { barchart(..., panel = function(x, y, ...) { panel.barchart(x, y, ...) } ) } x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), c = c(1,2,2,1)) f.barchart(a ~ b, data = x, groups = c) Which results in the following error being thrown: ..3 used in an incorrect context, no ... to look in When I use the following definition: f.barchart <- function(...) { substitute(barchart(..., panel = function(x, y, ...) { panel.barchart(x, y, ...) } )) } I get: barchart(a ~ b, data = x, groups = c, panel = function(x, y, ...) { panel.barchart(x, y, a ~ b, data = x, groups = c) }) I'm not sure if this is the cause of above error but this would mean that the ellipsis in panel.barchart gets wrongly expanded with the contents of the arguments given to f.barchart and not the panel function. Is there a way to avoid this problem? How can I make the function work? I use R 2.10.1 @ win32. Regards, Tom
lith
2010-Feb-19 08:58 UTC
[R] ellipsis-related error: used in an incorrect context, no ... to look in
Does nobody have an advice concerning that problem? If it is a FAQ, I'd appreciate a pointer to a discussion of this issue. With the docs accessible to me, I wasn't able to solve that problem.> ? ? require(lattice) > ? ? f.barchart <- function(...) { > ? ? ? ? barchart(..., > ? ? ? ? ? ? panel = function(x, y, ...) { > ? ? ? ? ? ? ? ? panel.barchart(x, y, ...) > ? ? ? ? ? ? } > ? ? ? ? ) > ? ? } > > ? ? x <- data.frame(a = c(1,1,2,2), b = c(1,2,3,4), c = c(1,2,2,1)) > ? ? f.barchart(a ~ b, data = x, groups = c) > > Which results in the following error being thrown: > > ? ? ..3 used in an incorrect context, no ... to look inRegards, Tom
Maybe Matching Threads
- dot-dot-dot as an actual argument
- lattice: How to display no box but only a y-axis on the left + Thicker lines
- missing factor levels in a lattice barchart panel cause unexpected failure
- barchart producing incorrect number of barcharts when columns renamed
- Lattice(barchart) related query