Bug: geom reevaluates args

3 views
Skip to first unread message

Stavros Macrakis

unread,
Apr 4, 2009, 5:39:17 PM4/4/09
to ggp...@googlegroups.com
qplot(rexp(10),rexp(10)) + geom_rug()

has the rugmarks in random (literally!) places, but rug seems to work fine for deterministic y's like sin(1:10).

I will guess that this is because it is re-evaluating rexp(10) rather than calculating the values once and reusing them.

Besides the problem in this non-deterministic case, I suppose this would also be a problem if the calculation were expensive.

I do realize that it is much better form, though, to precalculate the values and save them in a data frame.

         -s

ggplot2 0.8.2 (current CRAN version)
R 2.8.0
Windows Vista



hadley wickham

unread,
Apr 4, 2009, 6:30:38 PM4/4/09
to macr...@alum.mit.edu, ggp...@googlegroups.com
Hi Stavros,

Yes, this is unfortunate but I basically see no way to work around it
at the moment. I did originally have code that attempted to
reconstruct a data frame out of the arguments passed to qplot, but I
kept running into special cases that I couldn't work around, and now I
just capture the environment in which qplot is executed and evaluate
the arguments at plot-time.

Hadley
--
http://had.co.nz/
Reply all
Reply to author
Forward
0 new messages