hadley/ggplot2 — Issue #248: Variable scope is global when it should be local
Author: macrakis
Created: 2011-10-17 21:07:54+00:00
State: open

Arguments of aes are apparently evaluated in global environment (!!!) not local one:

df <- data.frame(a=1:10,b=10:1)

n<-3

n<-3; local({n<-2; ggplot(df) + geom_line(aes(x=a,y=b,group=cut(a,n)))})

Has ***3*** segments (global value of n), when it should have 2 (local value of n).