0
序因子濃度直我有一個簡單的數據集,看起來像這樣:使用GGPLOT2
school score grade subject
Your school 83.27 1 English
All schools 113.60 6 English
等級爲9級序的因素,學校是2級的一個因素。
'data.frame': 12762 obs. of 4 variables:
$ school : Factor w/ 2 levels "Your school",..: 1 2 2 2 2 2 2 2 2 2 ...
$ score : num 83.3 113.6 109.2 117.4 100.3 ...
$ grade : Ord.factor w/ 9 levels "1"<"2"<"3"<"4"<..: 1 6 6 7 4 3 6 1 6 6 ...
$ subject: chr "English" "English" "English" "English" ...
我想用ggplot2使用密度函數繪製一個多面直方圖。如果我嘗試沒有密度我得到這個:
p <- ggplot(ss, aes(x=grade))
p <- p + geom_histogram()
p <- p + facet_wrap(~school)
當我添加密度正常化y軸我得到這個:
p <- ggplot(ss, aes(x=grade))
p <- p + geom_histogram(aes(y=..density..))
p <- p + facet_wrap(~school)
什麼我錯過了嗎?
你能提供一個'str(ss)'嗎? – 2015-12-02 11:14:15
'data.frame':\t 12762 obs。 4個變量: $ school:因子w/2級別「Your school」,..:1 2 2 2 2 2 2 2 2 2 ... $ score:num 83.3 113.6 109.2 117.4 100.3 ... $ grade :Ord.factor w/9 levels「1」<「2」<「3」<「4」<..:1 6 6 7 4 3 6 1 6 6 ... $ subject:chr「English」「English 「」英語「」英語「... –
@Heroka它已經是。 –