對於以下的數據集,繪製彙總統計
Genre Amount
Comedy 10
Drama 30
Comedy 20
Action 20
Comedy 20
Drama 20
欲構建GGPLOT2線圖,其中x軸是Genre
和y軸是所有量的總和(在條件Genre
)。
我曾嘗試以下:
p = ggplot(test, aes(factor(Genre), Gross)) + geom_point()
p = ggplot(test, aes(factor(Genre), Gross)) + geom_line()
p = ggplot(test, aes(factor(Genre), sum(Gross))) + geom_line()
,但無濟於事。
整齊的單線......儘管你可以很容易地忽略因素,因爲stringsAsFactors '是默認行爲。 – aL3xa 2011-03-07 09:25:18
我想我會讓因子()指令,因爲它在問題中使用,但你是對的,在這裏沒有用。感謝您指出它。 – juba 2011-03-07 09:35:58
非常感謝,我使用係數的原因是因爲我試圖將總和從低到高,但是它沒有這樣做。 – 2011-03-07 09:50:54