如何自动刷新 R 包中的数据源?特别是冠状病毒 CRAN 包数据

How can I refresh a data source from an R package automatically? Specifically the coronavirus CRAN package data

我正在使用 Johns Hopkins 冠状病毒 R 包,但我还没有弄清楚如何让它每天为我提供基础更新数据。我已经重新启动 R 并重新加载了包,但从我安装包时开始,数据似乎是静态的。它不会在我每次 运行 时提供更新的数据,除非我重新安装软件包。这个包背后的数据每晚都会在存储库中更新。我正在尝试找出一种每天更新我的方法的好方法。

在此先感谢您提供的任何帮助!


library(coronavirus) 
library(dplyr)

data("coronavirus")

summary_df <- coronavirus %>% group_by(Country.Region, type) %>%
  summarise(total_cases = sum(cases)) %>%
  arrange(-total_cases)
df <- coronavirus %>%
  group_by(Province.State,Country.Region,Lat,Long,type) %>%
  mutate(TotalCasesRegion = cumsum(cases))```

一种选择是从包作者在 GitHub 上的项目中获取数据集(假设此数据按原样进入包)。

download.file("https://github.com/RamiKrispin/coronavirus/raw/master/data/coronavirus.rda", "cv")
load("cv")

似乎是最新的数据集:

max(coronavirus$date)
[1] "2020-03-04"

nrow(coronavirus)
[1] 2777