-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0732dcb
Showing
14 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# History files | ||
.Rhistory | ||
.Rapp.history | ||
|
||
# Session Data files | ||
.RData | ||
|
||
# Example code in package build process | ||
*-Ex.R | ||
|
||
# Output files from R CMD build | ||
/*.tar.gz | ||
|
||
# Output files from R CMD check | ||
/*.Rcheck/ | ||
|
||
# RStudio files | ||
.Rproj.user/ | ||
|
||
# produced vignettes | ||
vignettes/*.html | ||
vignettes/*.pdf | ||
|
||
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 | ||
.httr-oauth | ||
|
||
# knitr and R markdown default cache directories | ||
/*_cache/ | ||
/cache/ | ||
|
||
# Temporary files created by R markdown | ||
*.utf8.md | ||
*.knit.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Version: 1.0 | ||
|
||
RestoreWorkspace: Default | ||
SaveWorkspace: Default | ||
AlwaysSaveHistory: Default | ||
|
||
EnableCodeIndexing: Yes | ||
UseSpacesForTab: Yes | ||
NumSpacesForTab: 2 | ||
Encoding: UTF-8 | ||
|
||
RnwWeave: Sweave | ||
LaTeX: pdfLaTeX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Package: CoV19 | ||
Type: Package | ||
Title: Eli's package for figures and data on CoV-19 epidemic | ||
Version: 1.0 | ||
Date: 2020-03-22 | ||
Depends: | ||
R (>= 2.15.0), | ||
stringr, | ||
rmarkdown, | ||
knitr, | ||
ggplot2, | ||
grid | ||
Imports: Rdpack | ||
Author: Eli Holmes, Seattle, USA | ||
Maintainer: [email protected] | ||
Description: Code, figures and data | ||
License: GPL-2 | ||
LazyData: yes | ||
BuildVignettes: yes | ||
ByteCompile: TRUE | ||
RdMacros: Rdpack | ||
VignetteBuilder: knitr | ||
RoxygenNote: 7.0.2 | ||
Remotes: github::rstudio/rmarkdown | ||
Encoding: UTF-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## export functions | ||
export( | ||
getdatacovidtracking, | ||
getdatajhu | ||
) | ||
|
||
## Imports | ||
import(ggplot2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
This is a package for exploring some of the CoV-19 data. The world data is downloaded from JHU. The US data is downloaded from JHU and CovidTracking. The Italy data is downloaded from the Italian CDC (Protezione Civile) | ||
|
||
Sources: | ||
* https://github.com/CSSEGISandData/COVID-19 | ||
* https://covidtracking.com/api/ | ||
* https://github.com/pcm-dpc/COVID-19 | ||
|
||
To install the package | ||
|
||
``` | ||
library(devtools) | ||
install_github(eeholmes/CoV19) | ||
``` | ||
|
||
To get the data: | ||
``` | ||
statedata | ||
italydata | ||
worlddata | ||
``` | ||
Use `head()` to look at it. Should be pretty self-evident what it is. | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#' Download state data from Covid Tracking | ||
#' | ||
#' @param append Whether to append current numbers to an existing data frame (append=TRUE) or to download the whole time series again (append=FALSE). | ||
#' @return Saves a data frame to the data folder. | ||
#' @examples | ||
#' getdatacovidtrackint | ||
getdatacovidtracking <- function(append=TRUE){ | ||
if(append){ | ||
if(max(statedatadate) < Sys.Date()-1){ | ||
cat(paste0("No update because the state data file max date is ", max(statedatadate), " and appending would skip a day.\n")) | ||
return() | ||
} | ||
} | ||
if(!append){ | ||
url <- "http://covidtracking.com/api/states/daily.csv" | ||
statedata <- try(read.csv(url), silent=TRUE) | ||
if(!inherits(statedata, "try-error")){ | ||
save(statedata, file="states.RData") | ||
}else{ | ||
cat("Server error. Data could not be downloaded.\n") | ||
return() | ||
} | ||
}else{ | ||
load("data/states.RData") | ||
statedatadate <- as.Date(statedata$dateChecked) | ||
if(max(statedatadate) == Sys.Date()){ | ||
ans <- readline("The state data is has the same date as current date. Still update? (y/n)") | ||
if(ans != "y"){ cat("No update.\n"); return() } | ||
} | ||
save(statedata, file="data/statesold.RData") | ||
url <- "https://covidtracking.com/api/states.csv" | ||
stateday <- read.csv(url) | ||
stateday$date <- format(as.Date(stateday$dateChecked),"%Y%m%d") | ||
daydate <- as.Date(stateday$dateChecked)[1] | ||
statedata <- statedata[statedatadate != daydate,] | ||
statecols <- colnames(statedata) | ||
statedata <- rbind(stateday[,statecols],statedata) | ||
save(statedata, file="data/states.RData") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#' Download confirmed, deaths and recovered from github/pcm-dpc/COVID-19 | ||
#' | ||
#' @return Saves a data frame with region, date, positive, death, recovered, total hospitalized, and ICU to the data folder. | ||
#' @examples | ||
#' getdatajhu | ||
getdataitaly <- function(){ | ||
getx <- function(x, val){ | ||
x <- x[, !(colnames(x) %in% c("Lat","Long"))] | ||
library(tidyr) | ||
x %>% pivot_longer(cols=starts_with("X"),names_to="date", values_to = val) | ||
} | ||
url <- "https://raw.githubusercontent.com/pcm-dpc/COVID-19/master/dati-regioni/dpc-covid19-ita-regioni.csv" | ||
italydata <- try(read.csv(url), silent=TRUE) | ||
italydata$recovered <- italydata$totale_casi-italydata$totale_attualmente_positivi | ||
#rename | ||
iname <- c("data", "denominazione_regione", "totale_casi", "deceduti", "recovered", "totale_ospedalizzati", "terapia_intensiva") | ||
italydata <- italydata[,iname] | ||
colnames(italydata) <- c("date", "region", "positive", "death", "recovered", "hospitalized", "ICU") | ||
|
||
italydata$date <- as.Date(italydata$date) | ||
save(italydata, file="data/italy.RData") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#' Download confirmed, deaths and recovered from JHU | ||
#' | ||
#' @return Saves a data frame with Province.State, Country.Region, date, positive, death, and recovered to the data folder. | ||
#' @examples | ||
#' getdatajhu | ||
getdatajhu <- function(){ | ||
getx <- function(x, val){ | ||
x <- x[, !(colnames(x) %in% c("Lat","Long"))] | ||
library(tidyr) | ||
x %>% pivot_longer(cols=starts_with("X"),names_to="date", values_to = val) | ||
} | ||
url <- "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv" | ||
worlddataconfirmed <- try(read.csv(url), silent=TRUE) | ||
url <- "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Deaths.csv" | ||
worlddatadeaths <- try(read.csv(url), silent=TRUE) | ||
url <- "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Recovered.csv" | ||
worlddatarecovered <- try(read.csv(url), silent=TRUE) | ||
|
||
worlddata <- cbind(getx(worlddataconfirmed,"positive"),death=getx(worlddatadeaths,"death")$death, recovered=getx(worlddatarecovered,"recovered")$recovered) | ||
|
||
worlddata$date <- as.Date(str_remove(worlddata$date,"X"),"%m.%d.%y") | ||
save(worlddata, file="data/world.RData") | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.