0

I'm trying to create ezPlots for the visualisations of ANOVA for a subset o variables from my data frame, here's the code using the nasty eval hack (i haven't found other way to pass variables from the loop to ezPlot). The problem is that all the pdfs created by the loop are empty.

for (name in names[14:27]) {
    pdf(paste('./figs/', name ,'.pdf'))
    eval(parse(text=
    paste0('plot = ezPlot(data=df, 
           wid=Subject, 
           dv=',name,',
           between=Condition,
           within=Var, 
           type=3, 
           x=Var, 
           split=Condition)'
          )
    ))
    dev.off()
}
yemu
  • 26,249
  • 10
  • 32
  • 29

1 Answers1

1

it seems that in order to make ggplot print in functions one has to explicitly print the object, so adding

print(plot)

made my code working

yemu
  • 26,249
  • 10
  • 32
  • 29