[R] ggplot doesnt work in loops?

Steve Powell
Thu, 12 Jul 2007 07:38:59 -0000

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