我想從矩陣中創建一個箱形圖,其中幾個變量按兩個因子級別分組。矩陣的箱型圖由因子
一些樣本數據:
mymatrix = structure(list(Treatment = structure(c(1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 2L), .Label = c("con", "treat"), class = "factor"),
c1 = c(13L, 93L, 6L, 3L, 45L, 1L, 69L, 38L, 23L, 48L, 82L
), c5 = c(33L, 79L, 3L, 5L, 17L, 22L, 94L, 99L, 85L, 74L,
9L), c3 = c(96L, 52L, 0L, 6L, 60L, 14L, 69L, 96L, 57L, 99L,
39L), c8 = c(40L, 27L, 94L, 68L, 76L, 73L, 88L, 45L, 67L,
95L, 85L), c12 = c(20L, 14L, 53L, 9L, 93L, 1L, 12L, 45L,
59L, 38L, 25L)), .Names = c("Treatment", "c1", "c5", "c3",
"c8", "c12"), class = "data.frame", row.names = c("1a", "1b",
"2a", "2b", "3a", "3b", "4a", "4b", "5a", "5b", "5c"))
我能得到每個變量的箱線圖,但我不能在同一時間管理對他們組:提前
boxplot(as.matrix(mymatrix[,2:6]))
boxplot(as.matrix(mymatrix[,2:6])~Treatment, data=mymatrix)
感謝您的任何幫幫我。
有沒有辦法讓代碼更易讀? –
@LoïcFaure-Lacroix:這是將R數據發佈到SO的首選方式。這並不容易閱讀,但您可以將其複製並粘貼到您的R控制檯中並精確地再現對象。 –
@DrewSteen不熟悉R.謝謝你會記住這一點。 –