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)有多个群组
我想依每个群组去输出折线图,用循环写,最后每个图档都是一片空白
但是如果分开各写一段,就是不用循环,每个群组各自一段程式码
输出来的图档就完全没有问题
想请教各位先进,我该怎么处理?
谢谢~~