bars <- list(v=1:10, a=2:11)
barplot(bars, col=c("green", "black"))
Run Code Online (Sandbox Code Playgroud)
我无法理解为什么这段代码不起作用,我得到这个错误:
Error in -0.01 * height : non-numeric argument to binary operator
Run Code Online (Sandbox Code Playgroud)
更新: 我需要一个分组的条形图,每组有10组和两个条
Alp*_*pha 11
可能你想要这个:
bars <- cbind(1:10, 2:11)
barplot(bars, beside = TRUE, col = c("green", "black"))
Run Code Online (Sandbox Code Playgroud)
出现错误bars是因为是列表,高度必须是描述条形的值的向量或矩阵.
编辑:
为了得到10组2个条,你需要转置bars矩阵
barplot(t(bars), beside = TRUE, col = c("green", "black"))
Run Code Online (Sandbox Code Playgroud)

| 归档时间: |
|
| 查看次数: |
4690 次 |
| 最近记录: |