我正試圖用geom_bar產生一個相當簡單的堆積直方圖,但是垂直值並不能反映傳遞給ggplot調用的值。R - geom_bar不能產生正確的值
我正在使用的代碼:
p<-ggplot(data0, aes(x=variable, y=as.numeric(value), fill=season))
p+geom_bar(stat='identity')+ facet_grid(specie~region) + ...
其中str(data0)
寫着:
'data.frame': 720 obs. of 5 variables:
$ specie : Factor w/ 5 levels "","ozone.DU",..: 3 3 3 3 4 4 4 4 5 5 ...
$ season : Factor w/ 5 levels "","autumn (SON)",..: 3 4 2 5 3 4 2 5 3 4 ...
$ region : num 1 1 1 1 1 1 1 1 1 1 ...
$ variable: Factor w/ 15 levels "3","4","5","6",..: 1 1 1 1 1 1 1 1 1 1 ...
$ value : Factor w/ 736 levels "","1.872389649",..: 28 35 20 12 26 33 19 11 5
條生產不反映數據幀的任何值,並與價值不斷上升!
the values of the bars are not what I'd expect
任何建議是值得歡迎的。謝謝
你期望什麼? – mts
查看http://stackoverflow.com/questions/3418128/how-to-convert-a-factor-to-an-integer-numeric-without-a-loss-of-information。 (由於問題與ggplot2無關,所以此問題未來可能會受到限制) –