是否可以將關聯物件轉換為資料框,然后以某種方式將其用于繪圖?我需要這樣做的原因是因為我必須從安全服務器中匯出 CSV 格式的檔案(不允許發生事件物件并且不允許原始資料 - 但每月/每周計算良好)并在服務器外部生成圖。例如:
library(outbreaks)
library(ggplot2)
library(incidence)
dat <- ebola_sim$linelist$date_of_onset
i <- incidence(dat)
plot(i)
i_df <- as.data.frame(i)
有沒有辦法使用“i_df”資料框中的原始資料生成相同的圖?例如,它可以變成一個入射物件嗎?
uj5u.com熱心網友回復:
該incidence:::incidence.plot()
函式基本上是ggplot()/geom_col()
.. 的包裝器。對于您的特定示例資料集,您基本上可以做
ggplot(i_df, aes(dates,counts)) geom_col(width=1)
復制輸出的基本內容plot(i)
;對于完全復制,您可以更新標簽、軸等。
至于您的第二個問題,您可以通過執行以下操作從 恢復等效incidence
物件i_df
:
incidence(rep(i_df$dates, i_df$counts))
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/491401.html