[R] ggplot doesnt work in loops?

Steve Powell steve at promente.org
Thu Jul 12 09:38:59 CEST 2007


Dear list members
I am still a newbie so might be asking a stupid question, but I can't get
ggplot to work in a loop (or a "while" statement for that matter).
 
# to take a minimal example - 
mydata$varc = c(1,2,3)
for (i in 1:1){
        jpeg("test3.jpg")
        plot(mydata$varc)
        #ggplot(mydata, aes(x=mydata$varc)) + geom_bar()
        dev.off()
}

this produces an empty jpeg, whereas the content of the loop produces the
jpeg correctly.
a standard plot() does work inside the loop.
Any ideas? This is with R 2.4.0 and ggplot2
thanks in advance

Steve Powell

proMENTE social research



More information about the R-help mailing list