R - 绘制像直方图一样的数组

时间:2016-06-14 18:51:47

标签: r plot

我想在R中绘制数组的值:

a <- c( 276, 1591, 2367, 3441, 82, 2690, 106, 277, 172, 190, 26, 18, 32, 12, 12, 17)

以直方图的形式,如下所示:

hist(a, breaks="Sturge", col="grey", labels = T,main="My array")

enter image description here

但其值为y,而不是频率。

所以我想要的是一个简单的情节:

plot(a, type = 'h')

enter image description here

但布局类似于第一张图片(条形而不是线条)。

1 个答案:

答案 0 :(得分:3)

barplot(a)

barplot

正如@lmo所提到的,只需使用barplot代替plot :)