看板 R_Language 關於我們 聯絡資訊
f_levels <- levels(factor(s_score$GROUPS)) for (i in c(1:(length(f_levels)-1))) { stemp <- s_score[s_score$GROUPS == f_levels[i], ] stemp$CUNO <- paste(stemp$CUNO,"-",stemp$SNAME,"-",stemp$SPRANK,sep='') stemp <- stemp[, c("MONTH","CUNO","GROUPS","TOT_SCORE")] ylim_min <- 10 ylim_max <- 50 x11() png(filename=paste("group",f_levels[i],".png",sep=''),width=1280,height=720, units="px",pointsize=12,type="windows") ggplot(stemp, aes(x=factor(MONTH), y=TOT_SCORE, colour=CUNO, group=CUNO)) + geom_line(size=2) + geom_point(shape=10, size=4) + ylim(ylim_min, ylim_max) graphics.off() } 我的計分表(s_score)有多個群組 我想依每個群組去輸出折線圖,用迴圈寫,最後每個圖檔都是一片空白 但是如果分開各寫一段,就是不用迴圈,每個群組各自一段程式碼 輸出來的圖檔就完全沒有問題 想請教各位先進,我該怎麼處理? 謝謝~~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.230.103.154 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1650789496.A.7E4.html
lycantrope: g<- ggplot(...)後 print(g) 04/24 16:56
khaos: 真的是太感謝了~~~ 04/24 17:29