2012-10-28 58 views
0

我有想要繪製與我有這個數據集的某些圖形有點麻煩,數據集是類似於:原始數據轉換到頻率

 Year Count  ENSO   NAO 
1 1900  5 0.49063600 -0.073333333 
2 1901  7 -0.34351300 -0.461666667 
3 1902  5 1.43181000 -1.065000000 
4 1903  9 -0.48638500 0.335000000 
5 1904  5 0.66698600 -0.103333333 
6 1905  3 1.12753000 -0.818333333 
7 1906  8 -0.59783800 -0.040000000 
8 1907  2 -0.43226700 0.111666667 
9 1908  8 -0.48319500 0.421666667 
10 1909  8 -1.17421000 0.153333333 
11 1910  4 -0.68855800 -0.996666667 
12 1911  5 0.38084300 0.115000000 
13 1912  5 -0.06871800 -0.535000000 

而我想做的是能夠將「count」列並將其繪製爲「count」中每個值的頻率的條形圖,但是我不確定從哪裏開始,我正在查看的所有指南都只是顯示如何當你已經有相關的頻率時,將數據繪製成條形圖。

任何人都可以幫我嗎?

回答

3

這大概:

barplot(table(dat$Count)) 
1

不知道這是你在找什麼:

a <- rnorm(1000) 
h <- hist(a) 
barplot(h$counts, names=h$mids) 

與您的數據,你可以畫出:

barplot(df$Count, names=df$Year) 
0

一個ggplot2替代使用geom_bar

library(ggplot2) 
ggplot(dat, aes(x = factor(Count))) + geom_bar() + xlab('Count') 

enter image description here