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

问题描述 投票:0回答:1

我正在使用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))```
r automation refresh
1个回答
0
投票

[一种选择是从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
© www.soinside.com 2019 - 2024. All rights reserved.