R没有按顺序绘图(组)

时间:2014-09-18 11:57:11

标签: r plot

我对R很新, 这是下面的代码:

volume <- c(388,499,477,408,480,559,347,995,303,506,402,285,360,327,222,452,385,369,541,257,349,503,227,410,254,229,328,377,292,546,195,336,367)
stage <- c(rep("baseline",11),rep("preRT",11),rep("postRT",11))
prostatic_volume <- data.frame(volume,stage)

plot(volume ~ stage, 
     data=prostatic_volume,
     main="Change in prostatic volume during treatment",
     ylab="Prostatic volume, #voxels")

我希望它按baselinepreRtpostRt的顺序绘制。但由于某种原因,它混合了preRTpostRT的顺序。

我有什么想法可以解决这个问题吗?

提前致谢:)

1 个答案:

答案 0 :(得分:0)

在绘图之前可以更正数据框:

prostatic_volume$stage = factor(stage, levels=c('baseline','preRT','postRT'))