[R] defmacro and bwplot incompatibilities?

Geoffrey
Sun, 09 Dec 2012 11:11:34 -0000

My macro doesn't work for bwplot. But is working elsewhere.
What changes should i make to fix my macro.
Thanks.

The complete code sample is:
library(gtools)
library(lattice)

pic <- defmacro(fn, plotfunc, expr={png(filename=fn); plotfunc; dev.off()})

# this one fails.
pic("bw.png", {bwplot(Species ~ Sepal.Length, data=iris)})

# this one works
pic("p.png", {plot(iris$Sepal.Length)}