R: ggplot does not work if it is inside a for loop although it works outside of it -


this question has answer here:

i'm using simple ggplot function works fine outside loop not inside if iterative value not interfere ggplot function. why ?

here code

x=1:7 y=1:7 df = data.frame(x=x,y=y) ggplot(df,aes(x,y))+geom_point() 

it works ! if ggplot inside loop ...

for (i in 1:5) {    ggplot(df,aes(x,y))+geom_point() } 

... doesn't work anymore ! missing ?

thank you

when in for loop, have explicitly print your resulting ggplot object :

for (i in 1:5) {      print(ggplot(df,aes(x,y))+geom_point())  } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -