2
我嘗試使用ggplot2創建一個堆疊面積圖,下面是對此問題的答案(Getting a stacked area plot in R)中提供的示例。 我可以得到的例子工作很好,但是當執行方法我得到一個錯誤,我無法修復。ggplot2 - 面積圖錯誤
這裏是我的本錢:
我的數據是這樣的:
> head(trial)
Dates Day_Night day_propor
1 2013-01-01 N1 553
2 2013-01-01 D 981
3 2013-01-01 N2 866
4 2013-01-02 N1 553
5 2013-01-02 D 982
6 2013-01-02 N2 865
我再嘗試繪製圖表。
p1 <- ggplot(trial, aes(x=Dates,y=day_propor,group=Day_Night,fill=var)) + geom_area(position="fill")
,並得到一個錯誤
p1
Don't know how to automatically pick scale for object of type function. Defaulting to continuous
Error in data.frame(x = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, :
arguments imply differing number of rows: 1095, 0
錯誤似乎表明,在data.frame其中一列是錯誤的數據類,但我已經試過混合,每顆類進行匹配能想到的的。 爲了記錄在這裏,他們是:
> sapply(trial, class)
Dates Day_Night day_propor
"factor" "factor" "numeric"
我缺少什麼?
非常感謝。有時候一雙新鮮的眼睛會讓所有的不同。 –
不客氣! – tonytonov