put multiple plots on the same page using for loop

Hi, I'm trying to put multiple plots on the same page. I make several violin plots in a for loop and put them in a list named 'pliotplot'. However, I found that after running the for loop. All the violin plots are the same except that they have different titles. I've checked the 'pilotplot' list. I turned out that pilotplot[[1]] is different when m=1 and when m=2!! WHY?

pilotplot=list()
for (m in 1:15){
pilotplot[[m]]<-ggplot(pilotdata,aes(x=pilotdata[,{2m-1}],y=pilotdata[,(2m)]))+
geom_violin(trim=FALSE,fill="gray")+
labs(title=bodysite[m],x="velocity",y="pleasantness")+
geom_boxplot(width=0.1)+
theme_classic()
}
multiplot(plotlist=pilotplot,cols=3)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.