我正在尝试处理一项调查,我有Q1A到Q1H,答案是Q1,我想在R中的堆叠条形图中进行比较 . 所有这些都包含整数数据(分类) .
当我跑:
counts <- table(Q1A, Q1B, Q1C, Q1D, Q1E, Q1F, Q1G)
barplot(counts, main="Motivations for research",
xlab="motivation",
col=c('blue', 'green', 'red', 'orange', 'purple', 'yellow', 'grey'),
legend = rownames(counts))
我明白了:
Error in.... 'height' must be a vector or a matrix
我究竟做错了什么?这对ggplot2来说更容易吗?
/编辑:
Q1A和Q1B的输出输出为here .
1 回答
不太确定你的条形图应该是什么样的,所以我有几个例子给你 . 我也在使用
ggplot2
,plyr
和combine
包