使用以下資料和代碼時,我的 bar char 僅列印 1 個 bar,關于如何解決此問題的任何想法?
life_bar
# A tibble: 6 × 2
Continent mn
<chr> <dbl>
1 Africa 41.1
2 Americas 19.5
3 Eastern Mediterranean 47.0
4 Europe 15.6
5 South-East Asia 37.7
6 Western Pacific 16.4
使用的代碼;
ggplot(life_bar, aes(x = 'mn'))
geom_bar(fill = 'green', col = 'black')
uj5u.com熱心網友回復:
您需要同時指定x和y變數。x應該是Continent,y應該是mn。您不參考列名。
此外,在使用時,geom_bar()您需要指定如何聚合值 - 在您的情況下geom_bar(stat = "identity")。您可以通過使用來避免這種情況geom_col()。
ggplot(life_bar, aes(x = Continent, y = mn))
geom_col()
R eg 中有很多內置幫助,?geom_bar也有
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/435044.html
