Plotting a simple bargraph in R, Error: Height must be a vector of matrix
Plotting a simple bargraph in R, Error: Height must be a vector of matrix
这是我在 R 中的数据框,
New York 8755
Texas 7654
California 6726
Florida 6322
我只是想让图表比较 side.I 堆叠的条形图中的数字,但无法实现。
我收到错误 "Height must be a vector of Matrix."
请建议!
非常感谢!
R 在将整个 data.frame 传递给绘图时无法分辨哪个变量是哪个。在这种情况下,错误 'height' must be a vector or a matrix
告诉你你没有给 plot 函数它想要的东西。
对于 barplot
,使用 ?barplot
会告诉您需要什么:
barplot(height, width = 1, space = NULL,
names.arg = NULL ....
在你的例子中,你有一个 data.frame,第二列是身高,第一列是名字,所以你想做:
barplot(data[ ,2], names.arg = data[ ,1])
这是我在 R 中的数据框,
New York 8755
Texas 7654
California 6726
Florida 6322
我只是想让图表比较 side.I 堆叠的条形图中的数字,但无法实现。 我收到错误 "Height must be a vector of Matrix." 请建议! 非常感谢!
R 在将整个 data.frame 传递给绘图时无法分辨哪个变量是哪个。在这种情况下,错误 'height' must be a vector or a matrix
告诉你你没有给 plot 函数它想要的东西。
对于 barplot
,使用 ?barplot
会告诉您需要什么:
barplot(height, width = 1, space = NULL, names.arg = NULL ....
在你的例子中,你有一个 data.frame,第二列是身高,第一列是名字,所以你想做:
barplot(data[ ,2], names.arg = data[ ,1])