简体   繁体   中英

R - plot array like histogram

I want to plot the values of an array in R:

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

in a form like an histogram, like this:

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

在此处输入图片说明

but with its value as y, instead of the frequencies.

So what I want is a simple plot:

plot(a, type = 'h')

在此处输入图片说明

but with a layout like the first picture (bars instead of lines).

barplot(a)

条形图

As @lmo mentioned, just use barplot instead of plot :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM