質問
私はこのようになりますデータセットを持っている...
mine tonnes week AA 112 41 AA 114 41 AA 119 41 BB 108 41 BB 112 41 AA 110 42 AA 109 42 AA 102 43 AA 101 43
そして私は週ごとトンの分布を示すために、ggplot2で箱ひげ図を作成したいです。しかし、私は唯一の鉱山AAからの結果を望んでます。
私はそれがこのように働くだろうと思った....
qplot(factor(week), tonnes[mine == "AA"], data = sql_results, geom = "boxplot")
しかし、その代わりに、私はこのエラーを取得します。
Error in data.frame(x = c(13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, 13L, :
arguments imply differing number of rows: 423100, 109436
これは単純な、おそらく死んだが、私はこれを行うための正しい方法を考え出す多くの幸運を持っていないよ。
解決
があります。あなたの例では、なく、週の、トンのサブセットを作成します。
sql_results<-structure(list(mine = structure(c(1L, 1L, 1L, 2L, 2L, 1L, 1L,
1L, 1L), .Label = c("AA", "BB"), class = "factor"), tonnes = c(112,
114, 119, 108, 112, 110, 109, 102, 101), week = c(41, 41, 41,
41, 41, 42, 42, 43, 43)), row.names = c("1", "2", "3", "4", "5",
"6", "7", "8", "9"), .Names = c("mine", "tonnes", "week"), class = "data.frame")
qplot(factor(week), tonnes, data = subset(sql_results,mine=="AA"), geom = "boxplot")
所属していません StackOverflow