I am trying to create a wrapper for a trellised barchart function similar to this (to use the default ggplot theme):
require(ggplot2)
require(lattice)
require(latticeExtra)
data(Titanic)
mytheme = ggplot2like()
gbarchart = function(...) {
barchart(..., par.settings=mytheme)
}
gbarchart(Class ~ Freq | Sex + Age,
as.data.frame(Titanic),
groups = Survived,
stack = TRUE,
layout = c(4, 1),
auto.key = list(title = "Survived", columns = 2),
scales = list(x = "free"))
This gives an error:
Error in eval(expr, envir, enclos) :
..3 used in an incorrect context, no ... to look in
So far, if par.settings=mythemeadded to barchartdirectly, it works:
barchart(Class ~ Freq | Sex + Age,
as.data.frame(Titanic),
groups = Survived,
stack = TRUE,
layout = c(4, 1),
auto.key = list(title = "Survived", columns = 2),
scales = list(x = "free"),
par.settings=mytheme)

source
share