joachim-gassen / tidycovid19 Goto Github PK
View Code? Open in Web Editor NEW{tidycovid19}: An R Package to Download, Tidy and Visualize Covid-19 Related Data
Home Page: https://joachim-gassen.github.io/tidycovid19/
License: Other
{tidycovid19}: An R Package to Download, Tidy and Visualize Covid-19 Related Data
Home Page: https://joachim-gassen.github.io/tidycovid19/
License: Other
Since the data cache in GitHub hasn't been updated in the last 2 days, I tried to use
download_merged_data(cached=FALSE)
It fails with the following error:
.
.
.
Start downloading Google Trends data
Pulling Google trend data for IT ...Error in `[<-.data.frame`(`*tmp*`, , timevar, value = "subject") :
replacement has 1 row, data has 0
In addition: Warning messages:
1: In countrycode::countrycode(.data$`Country/Region`, origin = "country.name", :
Some values were not matched unambiguously: Diamond Princess, Kosovo, MS Zaandam
2: In countrycode::countrycode(.data$`Country/Region`, origin = "country.name", :
Some values were not matched unambiguously: Diamond Princess, Kosovo, MS Zaandam
3: In countrycode::countrycode(.data$`Country/Region`, origin = "country.name", :
Some values were not matched unambiguously: Diamond Princess, Kosovo, MS Zaandam
4: In countrycode::countrycode(.data$country, origin = "country.name", :
Some values were not matched unambiguously: Diamond Princess, Kosovo, MS Zaandam
Maybe the Google Trends
API/data format just changed? Can you fix it, or otherwise add an option to make downloading the Google Trends
optional? Thanks!
First of all, let me make you the compliments for this excellent package, which should get more publicity.
Secondly, as per subject:
remotes::install_github("joachim-gassen/tidycovid19")
#> Skipping install of 'tidycovid19' from a github remote, the SHA1 (04fc58e9) has not changed since last install.
#> Use `force = TRUE` to force installation
if (!require("pacman")) install.packages("pacman")
#> Loading required package: pacman
pacman::p_load(dplyr,
tidycovid19)
# Download latest data
updates <- download_merged_data(cached = TRUE)
#> Downloading cached version of merged data...
#> done. Timestamp is 2020-04-24 10:11:16
# Countries to highlight
countries <- "CHN"
print(plot_covid19_spread(updates,
highlight = countries,
type = "deaths",
per_capita = TRUE,
exclude_others = TRUE))
#> Warning in plot_covid19_spread(updates, highlight = countries, type =
#> "deaths", : Non-NULL 'highlight' value but no countries matched in data (Did you
#> specify correct ISO3c codes?)
Created on 2020-04-24 by the reprex package (v0.3.0)
NOTE: plot_covid19_spread
complains that CHN
doesn't correspond to any country Warning in plot_covid19_spread(updates, highlight = countries, type = "deaths", : Non-NULL 'highlight' value but no countries matched in data (Did you specify correct ISO3c codes?)
. However, this is wrong: CHN
is indeed the correct ISO3c code for China, see:
https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
https://unstats.un.org/unsd/tradekb/knowledgebase/country-code
Hi Joachim
Really appreciate the work you are doing.
Do you plan on updating the Oxford data to include their recent modifications? I have followed you discussion of the issue with their approach but still think it is valuable to compare sources
https://www.bsg.ox.ac.uk/research/research-projects/coronavirus-government-response-tracker
Thanks
Guido
Hi,
Fantastic work! I use your package frequently for policy work. Thanks!
And for the issue: would it be possible to add Appl's Mobility Trends Report to the package?
https://www.apple.com/covid19/mobility
Thank you for considering,
Itamar
Hi Joachim,
this is more of a suggestion than a real issue, so feel free to close it if you think it's out of scope for the package.
A visualization which is extremely helpful to estimate when an epidemic will die out, is the epidemic curve, i.e., a barplot of daily new confirmed cases:
or a barplot of cases by symptoms insurgence:
Would it be possible to add it to the possible plots? Especially when trying to nowcast or forecast R_t, it's a real life-saver.
PS you can already do something quite similar with the following settings:
updates <- download_merged_data(cached = TRUE)
# Countries to highlight
countries <- "DEU"
print(plot_covid19_spread(updates,
highlight = countries,
type = "confirmed",
cumulative = FALSE,
min_cases = 1,
edate_cutoff = 1000,
per_capita = FALSE,
change_ave = 1,
log_scale = FALSE,
exclude_others = TRUE,
intervention = "lockdown"))
However, having the possibility to use a barplot rather than a lineplot would lead to a more familiar graph for epidemiologists. Since barplots quickly become cumbersome for multiple countries, rather than adding this as an option in plot_covid19_spread
, I'd suggest to add a new function, maybe plot_epidemic_curve
, which by default:
instead than
Hi,
Would it be possible to add a function that downloads and tidies the Waze mobility data to the package?
Thanks,
Itamar
When comparing per capita plots among countries, one should not set the origin of the x-axis to the day the same number of cases/deaths was reached (i.e., use absolute values to define the 'event date' cutoff set by min_cases
), but to the day the same fraction of cases/deaths was reached. This is clearly explained by renown epidemiologists and medical researchers here:
https://twitter.com/CT_Bergstrom/status/1249491368507932672?s=20
here:
https://twitter.com/EricTopol/status/1249771636712067073?s=20
and here:
https://twitter.com/CT_Bergstrom/status/1249930299258990592?s=20
Now, in your excellent function plot_covid19_spread
, setting per_capita_x_axis = TRUE
whenever per_capita = TRUE
is sufficient to get this kind of plot, according to plot_covid19_spread
help:
per_capita_x_axis | If TRUE, the 'event date' cutoff for the x axis set by min_cases is evaluated based on by capita measures (cases per 100,000 inhabitants). Only feasible when per_capita is TRUE. Defaults to FALSE.
However, currently the default per_capita_x_axis
is FALSE
, irrespective of the value of per_capita
. In order to promote plotting best practices, I suggest to set the default value of per_capita_x_axis
so that it follows the value of per_capita
. In other words, I suggest setting the following default value:
.
.
.
per_capita = FALSE,
per_capita_x_axis = ifelse(per_capita, TRUE, FALSE),
.
.
.
I receive the following error when trying to download non-cached data:
Error: Column
_isonot found in
.data Run
rlang::last_error()to see where the error occurred. In addition: Warning messages: 1: Problem with
mutate()input
iso3c`.
ℹ Some values were not matched unambiguously: Diamond Princess, Kosovo, MS Zaandam
ℹ Input iso3c
is countrycode::countrycode(...)
.
2: In countrycode::countrycode(.data$Country/Region
, origin = "country.name", :
Some values were not matched unambiguously: Diamond Princess, Kosovo, MS Zaandam
3: Problem with mutate()
input iso3c
.
ℹ Some values were not matched unambiguously: Diamond Princess, Kosovo, MS Zaandam
ℹ Input iso3c
is countrycode::countrycode(...)
.
4: In countrycode::countrycode(.data$Country/Region
, origin = "country.name", :
Some values were not matched unambiguously: Diamond Princess, Kosovo, MS Zaandam
5: Problem with mutate()
input iso3c
.
ℹ Some values were not matched unambiguously: Diamond Princess, Kosovo, MS Zaandam
ℹ Input iso3c
is countrycode::countrycode(...)
.
6: In countrycode::countrycode(.data$Country/Region
, origin = "country.name", :
Some values were not matched unambiguously: Diamond Princess, Kosovo, MS Zaandam
7: In countrycode::countrycode(.data$country, origin = "country.name", :
Some values were not matched unambiguously: Diamond Princess, Kosovo, MS Zaandam`
Hi again,
I get Error: Cannot parse the supplied time format.
when running download_google_trends_data("coronavirus")
. I'm in New Zealand so it is already April 1 here. I think this is outside the time window for google trends at the moment.
I would suggest changing time <- paste("2020-01-01", Sys.Date())
to something like time <- paste("2020-01-01", lubridate::today(tzone = "Europe/Berlin"))
or whichever timezone makes sense.
Cheers
Might be good idea to scrape data from https://www.worldometers.info/coronavirus/
which includes some interesting data like "Total Tests".
Hi,
I was trying to access the data using the code below but it returns error message instead.
merged <- download_merged_data(silent = TRUE, cached = FALSE)
Error in `[<-.data.frame`(`*tmp*`, , timevar, value = "subject") :
replacement has 1 row, data has 0
Can you help me fixing the issue? Thanks in advance.
Alemu
Dear Joachim Gassen. I will greatly appreciate your help. I can not install the package
remotes::install_github("joachim-gassen/tidycovid19")
Error: Failed to install 'tidycovid19' from GitHub:
(converted from warning) cannot remove prior installation of package ‘curl’
In addition: Warning messages:
1: In untar2(tarfile, files, list, exdir) :
skipping pax global extended headers
2: In untar2(tarfile, files, list, exdir) :
skipping pax global extended headers
Thank you in advance
Paula Fergnani
The Oxford COVID-19 Government Response Tracker (OxCGRT) changed its variables and variable names so the function is not working anymore. Hope that there will be an update! Thank you.
Small issue with writeup and maybe naming, not necessarily the underlying code: In Readme.md, the new function download_owid_data()
has its description beginning "Downloads and tidies data collected by the ‘Our World in Data’ team". The second sentence says specifically "This team systematically collects data on hospitalizations, testing and vaccinations from multiple national sources." The first statement might slightly mislead as really this function is confined to downloading just COVID testing data, not the entire range of other COVID data that OWID reports. (Scanning the R code confirms this.) Small suggestion is that a fix might either (a) remove the select
and filter
statements, and edit the description; (b) rename the function to make clearer it's confined to just covid testing data.
Or perhaps, is the function still work in progress to something larger?
Many thanks for all the excellent and valuable work this REPO represents.
*****EDIT
nevermind
the data are missing from the OWID repo as well
sorry
Hi,
I noticed that since last week or so testing data from Czechia is missing from the merged (cached) data and the owid testing data. However testing data for the country is available at the OWID repository.
Thanks,
Álvaro
Would it be possible to add regional/subregional data to the GCMR download function?
Hey, I was trying to download the package in my computer, it returns an error.
install.packages("remotes")
remotes::install_github("joachim-gassen/tidycovid19")
Downloading GitHub repo joachim-gassen/tidycovid19@HEAD
Error in utils::download.file(url, path, method = method, quiet = quiet, :
download from 'https://api.github.com/repos/joachim-gassen/tidycovid19/tarball/HEAD' failed
I'm trying to use the packge to extract data from Brazil's report using the code below:
I'm using Windows 10 and R 3.6.3
#remotes::install_github("joachim-gassen/tidycovid19")
library(tidycovid19)
library(tidyverse)
library(pdftools)
library(png)
pdf_url <- "https://www.gstatic.com/covid19/mobility/2020-04-05_BR_Mobility_Report_en.pdf"
pdf_convert(pdf_url, pages = 1, filenames = "google_cmr_de_p1.png", verbose = FALSE)
bitmaps <- tidycovid19:::extract_line_graph_bitmaps(pdf_url, 1)
png_file <- tempfile("bitmap_", fileext = ".png")
writePNG(bitmaps[[1]][[1]], "bitmap.png")
df <- tidycovid19:::parse_line_graph_bitmap(bitmaps[[1]][[1]])
In the line "bitmaps <- tidycovid19:::extract_line_graph_bitmaps(pdf_url, 1)
" it return the following error:
This may just be me making some mistake, but:
remotes::install_github("joachim-gassen/tidycovid19")
#> Skipping install of 'tidycovid19' from a github remote, the SHA1 (56a8bd32) has not changed since last install.
#> Use `force = TRUE` to force installation
if (!require("pacman")) install.packages("pacman")
#> Loading required package: pacman
pacman::p_load(dplyr,
tidycovid19)
# Download latest data
updates <- download_merged_data(cached = TRUE)
#> Downloading cached version of merged data...
#> done. Timestamp is 2020-05-10 08:06:23
#>
#> Data Info:
#> This data frame contains Covid-19 related data from multiple sources in
#> a country-day structure. Data sources are JHU CSSE data on confirmed
#> cases, deaths and recoveries
#> (https://github.com/CSSEGISandData/COVID-19), 'Our World in Data' data
#> on testing (https://ourworldindata.org/covid-testing), ACAPS data on
#> governmental measures
#> (https://www.acaps.org/covid19-government-measures-dataset), Apple's
#> Mobility Trend Reports on Apple Map usage
#> (https://www.apple.com/covid19/mobility), Google's Community Mobility
#> Reports on individual movement trends
#> (https://www.google.com/covid19/mobility/), Google Trends data on
#> relative Google search volumes for the term 'coronavirus'
#> (https://trends.google.com/) and country-level World Bank data on
#> population (density), life expectancy and national income
#> (https://data.worldbank.org). The data frame
#> 'tidycovid19_variable_definitions' holds definitions for each variable
#> in this data frame. The data frame 'tidycovid19_data_sources' contains
#> more information on the data sources included in this package. The
#> column 'timestamp' reports the time the data was downloaded from its
#> authoritative source.
#>
#> For further information refer to:
#> https://github.com/joachim-gassen/tidycovid19.
#>
# Countries to highlight
Taiwan <- "TWN"
print(plot_covid19_spread(updates,
highlight = Taiwan,
type = "confirmed",
cumulative = TRUE,
min_cases = 1,
min_by_ctry_obs = 1,
edate_cutoff = 50,
per_capita = FALSE,
log_scale = FALSE,
exclude_others = TRUE))
#> Warning in plot_covid19_spread(updates, highlight = Taiwan, type =
#> "confirmed", : Non-NULL 'highlight' value but no countries matched in data (Did
#> you specify correct ISO3c codes or do values for 'min_cases', 'min_by_ctry_obs'
#> and/or 'edate_cutoff' lead to the exclusion of your selected countries' data?)
Created on 2020-05-11 by the reprex package (v0.3.0)
min_cases
is 1, and Taiwan indeed had at least 1 case: https://ig.ft.com/coronavirus-chart/?areas=twn&areas=kor&cumulative=1&logScale=1&perMillion=0&values=casesmin_by_ctry_obs
is set to 1, so this shouldn't be a problem eitheredate_cutoff
, set to 50 so there should be plenty of data to showCould this be related to the fact that the first confirmed
datapoint for Taiwan is a NA
?
> filter(updates, iso3c == "TWN")
# A tibble: 110 x 35
iso3c country date confirmed deaths recovered ecdc_cases ecdc_deaths total_tests tests_units soc_dist mov_rest
<chr> <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <chr> <dbl> <dbl>
1 TWN Taiwan 2020-01-21 NA NA NA 1 0 NA NA NA NA
2 TWN Taiwan 2020-01-22 1 0 0 1 0 NA NA NA NA
3 TWN Taiwan 2020-01-23 1 0 0 1 0 NA NA NA NA
4 TWN Taiwan 2020-01-24 3 0 0 1 0 NA NA NA NA
5 TWN Taiwan 2020-01-25 3 0 0 3 0 NA NA NA NA
6 TWN Taiwan 2020-01-26 4 0 0 3 0 NA NA NA NA
7 TWN Taiwan 2020-01-27 5 0 0 5 0 NA NA NA NA
8 TWN Taiwan 2020-01-28 8 0 0 7 0 NA NA NA NA
9 TWN Taiwan 2020-01-29 8 0 0 8 0 NA NA NA NA
10 TWN Taiwan 2020-01-30 9 0 0 8 0 NA NA NA NA
# … with 100 more rows, and 23 more variables: pub_health <dbl>, gov_soc_econ <dbl>, lockdown <dbl>,
# apple_mtr_driving <dbl>, apple_mtr_walking <dbl>, apple_mtr_transit <dbl>, gcmr_retail_recreation <dbl>,
# gcmr_grocery_pharmacy <dbl>, gcmr_parks <dbl>, gcmr_transit_stations <dbl>, gcmr_workplaces <dbl>,
# gcmr_residential <dbl>, gtrends_score <dbl>, gtrends_country_score <int>, region <chr>, income <chr>,
# population <dbl>, land_area_skm <dbl>, pop_density <dbl>, pop_largest_city <dbl>, life_expectancy <dbl>,
# gdp_capita <dbl>, timestamp <dttm>
Hi! Thanks for the great package.
Looks to me like there's a bug in the gtrendsR
package (in gtrendsR:::related_topics
) that's affecting download_google_trends_data
.
Might be worth wrapping all the functions that make up download_merged_data
in a trycatch (maybe a purrr::possibly
with otherwise
set to tibble()
) so that download_merged_data
can download all sources that are currently working. Happy to do that and submit a PR if you like.
Let me know if you want any more info on the bug.
library(tidycovid19)
download_google_trends_data()
#> Start downloading Google Trends data
#> Pulling Google trend data for IT ...
#> Error in `[<-.data.frame`(`*tmp*`, , timevar, value = "subject"): replacement has 1 row, data has 0
packageVersion("tidycovid19")
#> [1] '0.0.0.9000'
packageVersion("gtrendsR")
#> [1] '1.4.6'
devtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.0.0 (2020-04-24)
#> os macOS Catalina 10.15.5
#> system x86_64, darwin17.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2020-06-14
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib
#> anytime 0.3.7 2020-01-20 [1]
#> assertthat 0.2.1 2019-03-21 [1]
#> backports 1.1.7 2020-05-13 [1]
#> callr 3.4.3 2020-03-28 [1]
#> cli 2.0.2 2020-02-28 [1]
#> colorspace 1.4-1 2019-03-18 [1]
#> countrycode 1.2.0 2020-05-22 [1]
#> crayon 1.3.4 2017-09-16 [1]
#> curl 4.3 2019-12-02 [1]
#> desc 1.2.0 2018-05-01 [1]
#> devtools 2.3.0 2020-04-10 [1]
#> digest 0.6.25 2020-02-23 [1]
#> dplyr 1.0.0 2020-05-29 [1]
#> ellipsis 0.3.1 2020-05-15 [1]
#> evaluate 0.14 2019-05-28 [1]
#> fansi 0.4.1 2020-01-08 [1]
#> fastmap 1.0.1 2019-10-08 [1]
#> fs 1.4.1 2020-04-04 [1]
#> generics 0.0.2 2018-11-29 [1]
#> ggplot2 3.3.1 2020-05-28 [1]
#> ggrepel 0.8.2 2020-03-08 [1]
#> glue 1.4.1 2020-05-13 [1]
#> gtable 0.3.0 2019-03-25 [1]
#> gtrendsR 1.4.6 2020-05-17 [1]
#> highr 0.8 2019-03-20 [1]
#> htmltools 0.4.0 2019-10-04 [1]
#> httpuv 1.5.4 2020-06-06 [1]
#> jsonlite 1.6.1 2020-02-02 [1]
#> knitr 1.28 2020-02-06 [1]
#> later 1.1.0.1 2020-06-05 [1]
#> lifecycle 0.2.0 2020-03-06 [1]
#> lubridate 1.7.8 2020-04-06 [1]
#> magrittr 1.5 2014-11-22 [1]
#> memoise 1.1.0 2017-04-21 [1]
#> mime 0.9 2020-02-04 [1]
#> munsell 0.5.0 2018-06-12 [1]
#> pillar 1.4.4 2020-05-05 [1]
#> pkgbuild 1.0.8 2020-05-07 [1]
#> pkgconfig 2.0.3 2019-09-22 [1]
#> pkgload 1.1.0 2020-05-29 [1]
#> prettyunits 1.1.1 2020-01-24 [1]
#> processx 3.4.2 2020-02-09 [1]
#> promises 1.1.0 2019-10-04 [1]
#> ps 1.3.3 2020-05-08 [1]
#> purrr 0.3.4 2020-04-17 [1]
#> R6 2.4.1 2019-11-12 [1]
#> rclipboard 0.1.2 2019-07-02 [1]
#> Rcpp 1.0.4.6 2020-04-09 [1]
#> remotes 2.1.1 2020-02-15 [1]
#> rlang 0.4.6 2020-05-02 [1]
#> rmarkdown 2.2 2020-05-31 [1]
#> rprojroot 1.3-2 2018-01-03 [1]
#> scales 1.1.1 2020-05-11 [1]
#> sessioninfo 1.1.1 2018-11-05 [1]
#> shiny 1.4.0.2 2020-03-13 [1]
#> shinyjs 1.1 2020-01-13 [1]
#> shinyWidgets 0.5.3 2020-06-01 [1]
#> stringi 1.4.6 2020-02-17 [1]
#> stringr 1.4.0 2019-02-10 [1]
#> testthat 2.3.2 2020-03-02 [1]
#> tibble 3.0.1 2020-04-20 [1]
#> tidycovid19 * 0.0.0.9000 2020-06-14 [1]
#> tidyselect 1.1.0 2020-05-11 [1]
#> usethis 1.6.1 2020-04-29 [1]
#> vctrs 0.3.1 2020-06-05 [1]
#> withr 2.2.0 2020-04-20 [1]
#> xfun 0.14 2020-05-20 [1]
#> xtable 1.8-4 2019-04-21 [1]
#> yaml 2.2.1 2020-02-01 [1]
#> source
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> Github (joachim-gassen/tidycovid19@005f805)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#> CRAN (R 4.0.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/4.0/Resources/library
Created on 2020-06-14 by the reprex package (v0.3.0)
Hi, I am trying to install the package but my name has a special character "á", so I get the following error message:
Installing package into ‘C:/Users/Otávio/OneDrive/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
Any clue on how to fix this?
I can successfully install regular R packages in my RStudio.
Thank you!
I have seen a blog using tidycovid19 package of yours, it gives great depth of data and collectively collecting some interesting aspect. Can I confirm that in tidycovid19, there is a function named extract_line_graph_bitmaps? I see it from the example from https://www.r-bloggers.com/scraping-google-covid-19-community-movement-data-from-pdf-figures/. However, I could not call or find script from the github repo.
Hi!
I used the following script in R Studio:
install.packages("remotes")
remotes::install_github("joachim-gassen/tidycovid19")
Then, once I enter the option 1 (All) in order to update all the available packages, the following message appears:
Error: Failed to install 'tidycovid19' from GitHub:
(convertido del aviso) packages ‘jsonlite’, ‘tibble’ are in use and will not be installed
Además: Warning messages:
1: In untar2(tarfile, files, list, exdir) :
skipping pax global extended headers
2: In untar2(tarfile, files, list, exdir) :
skipping pax global extended headers
Please, could you help me? I would like to use the library "tidycovid19".
Thanks in advance.
Dear all,
I recently re-tried to install tidycovid on R v4.0 from the function install_github.
Everything worked perfectly except for the dependency : wbstats.
I received the error message :
Installing package into ‘C:/Users/usr/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
ERROR: dependency 'wbstats' is not available for package 'tidycovid19'
When checking on CRAN, I just saw that the package has been removed :
https://cran.r-project.org/web/packages/wbstats/index.html
Would you know how to handle this issue ?
Kind regards,
Cannot seem to download the package as remotes::install_github("joachim-gassen/tidycovid19") does not find the tarball
I ask plot_covid19_spread
to highlight both Sweden and Norway, but only Sweden is highlighted. The ISO3c codes for both countries are correct, as it can be verified here. Reprex:
remotes::install_github("joachim-gassen/tidycovid19")
#> Skipping install of 'tidycovid19' from a github remote, the SHA1 (93f1ceab) has not changed since last install.
#> Use `force = TRUE` to force installation
if (!require("pacman")) install.packages("pacman")
#> Carico il pacchetto richiesto: pacman
pacman::p_load(dplyr,
tidycovid19)
# Download latest data
updates <- download_merged_data(cached = TRUE)
#> Downloading cached version of merged data...
#> done. Timestamp is 2020-04-19 07:28:36
# Countries to highlight
countries <- c("SWE", "NOR")
print(plot_covid19_spread(updates,
highlight = countries,
per_capita = TRUE))#
# per_capita_x_axis = TRUE)
Created on 2020-04-20 by the reprex package (v0.3.0)
min_by_ctry_obs | Limits the plot to countries that have at least that many days of dater since and including the event date. Defaults to 7
I think dater
should be data
.
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 3.6.0 (2019-04-26)
os Ubuntu 16.04.6 LTS
system x86_64, linux-gnu
ui RStudio
language (EN)
collate C.UTF-8
ctype C.UTF-8
tz Etc/UTC
date 2020-04-17
─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] RSPM (R 3.6.0)
cellranger 1.1.0 2016-07-27 [1] RSPM (R 3.6.0)
cli 2.0.2 2020-02-28 [1] RSPM (R 3.6.0)
colorspace 1.4-1 2019-03-18 [1] RSPM (R 3.6.0)
crayon 1.3.4 2017-09-16 [1] RSPM (R 3.6.0)
curl 4.3 2019-12-02 [1] RSPM (R 3.6.0)
data.table 1.12.8 2019-12-09 [1] RSPM (R 3.6.0)
digest 0.6.25 2020-02-23 [1] RSPM (R 3.6.0)
dplyr * 0.8.5 2020-03-07 [1] RSPM (R 3.6.0)
ellipsis 0.3.0 2019-09-20 [1] RSPM (R 3.6.0)
evaluate 0.14 2019-05-28 [1] RSPM (R 3.6.0)
fansi 0.4.1 2020-01-08 [1] RSPM (R 3.6.0)
forcats 0.5.0 2020-03-01 [1] RSPM (R 3.6.0)
foreign 0.8-71 2018-07-20 [2] CRAN (R 3.6.0)
ggplot2 3.3.0 2020-03-05 [1] CRAN (R 3.6.0)
glue 1.4.0 2020-04-03 [1] RSPM (R 3.6.0)
gtable 0.3.0 2019-03-25 [1] RSPM (R 3.6.0)
haven 2.2.0 2019-11-08 [1] RSPM (R 3.6.0)
hms 0.5.3 2020-01-08 [1] RSPM (R 3.6.0)
htmltools 0.4.0 2019-10-04 [1] RSPM (R 3.6.0)
httr 1.4.1 2019-08-05 [1] RSPM (R 3.6.0)
kableExtra * 1.1.0 2019-03-16 [1] RSPM (R 3.6.0)
knitr * 1.28 2020-02-06 [1] RSPM (R 3.6.0)
lifecycle 0.2.0 2020-03-06 [1] RSPM (R 3.6.0)
magrittr 1.5 2014-11-22 [1] RSPM (R 3.6.0)
munsell 0.5.0 2018-06-12 [1] RSPM (R 3.6.0)
openxlsx 4.1.4 2019-12-06 [1] RSPM (R 3.6.0)
pacman * 0.5.1 2019-03-11 [1] RSPM (R 3.6.0)
pillar 1.4.3 2019-12-20 [1] RSPM (R 3.6.0)
pkgconfig 2.0.3 2019-09-22 [1] RSPM (R 3.6.0)
purrr 0.3.3 2019-10-18 [1] RSPM (R 3.6.0)
R6 2.4.1 2019-11-12 [1] RSPM (R 3.6.0)
Rcpp 1.0.4.6 2020-04-09 [1] RSPM (R 3.6.0)
readr 1.3.1 2018-12-21 [1] RSPM (R 3.6.0)
readxl 1.3.1 2019-03-13 [1] RSPM (R 3.6.0)
rio * 0.5.16 2018-11-26 [1] RSPM (R 3.6.0)
rlang 0.4.5 2020-03-01 [1] RSPM (R 3.6.0)
rmarkdown 2.1 2020-01-20 [1] RSPM (R 3.6.0)
rstudioapi 0.11 2020-02-07 [1] RSPM (R 3.6.0)
rvest 0.3.5 2019-11-08 [1] RSPM (R 3.6.0)
scales 1.1.0 2019-11-18 [1] RSPM (R 3.6.0)
sessioninfo 1.1.1 2018-11-05 [1] RSPM (R 3.6.0)
stringi 1.4.6 2020-02-17 [1] RSPM (R 3.6.0)
stringr 1.4.0 2019-02-10 [1] RSPM (R 3.6.0)
tibble 3.0.0 2020-03-30 [1] RSPM (R 3.6.0)
tidycovid19 * 0.0.0.9000 2020-04-17 [1] Github (joachim-gassen/tidycovid19@4ccb731)
tidyselect 1.0.0 2020-01-27 [1] RSPM (R 3.6.0)
vctrs 0.2.4 2020-03-10 [1] RSPM (R 3.6.0)
viridisLite 0.3.0 2018-02-01 [1] RSPM (R 3.6.0)
wbstats * 0.2 2018-01-03 [1] RSPM (R 3.6.0)
webshot 0.5.2 2019-11-22 [1] RSPM (R 3.6.0)
withr 2.1.2 2018-03-15 [1] RSPM (R 3.6.0)
xfun 0.12 2020-01-13 [1] RSPM (R 3.6.0)
xml2 1.3.1 2020-04-09 [1] RSPM (R 3.6.0)
zip 2.0.4 2019-09-01 [1] RSPM (R 3.6.0)
[1] /home/rstudio-user/R/x86_64-pc-linux-gnu-library/3.6
[2] /opt/R/3.6.0/lib/R/library
Hi,
First of all, thanks for all your work in standing up this repository.
I am having an issue running download_acaps_npi_data()
- I get the following error: Error: Evaluation error: error -103 with zipfile in unzGetCurrentFileInfo
. I narrowed it down to
tmp_file <- tempfile(".xlsx")
utils::download.file(paste0("https://data.humdata.org",
dta_url), tmp_file, quiet = silent)
raw_dta <- readxl::read_excel(tmp_file, sheet = "Database")
The downloaded excel sheet is corrupted so won't open. I'm on Windows, so I think the issue is that the mode for utils::download.file()
needs to be set to "wb" (this doesn't seem to be an issue for Unix-like OS - which I assume you're on). I.e.
tmp_file <- tempfile(".xlsx")
utils::download.file(paste0("https://data.humdata.org",
dta_url), tmp_file, quiet = silent, mode = "wb")
raw_dta <- readxl::read_excel(tmp_file, sheet = "Database")
Kind regards
After upgrading to R 4.0 I cannot run my scripts on the Corona pandemic. The library is not available for install. Please fix
According to plot_covid19_spread
help, the value active
for the argument type
is defined as:
"active", defined as the difference of "confirmed" and "recovered".
As a matter of fact, the corresponding code does exactly that:
tidycovid19/R/plot_covid19_spread.R
Line 116 in 0b0bf27
Is this correct? Shouldn't it be confirmed -deaths - recovered
, instead than just confirmed-recovered
? I.e.
dplyr::mutate(active = .data$confirmed - .data$recovered - .data$deaths)
BTW, I made a PR to correct a small typo in the help, you may want to check it out 😉
Hello Joachim,
Thank u for this great job and for adding Google Trends data.
I have two questions:
Why there are no results for Israel (and some other countries) while from this link I can get the results?
https://trends.google.fr/trends/explore?cat=16&date=2019-12-31%202020-05-30&geo=IL&q=CORONAVIRUS
Is it possible to modify the search string this way?
search_term = c('coronavirus', 'COVID', 'קורונה', 'קוביד')
Thank you !!!
Yan Ouaknine
Thank you for the package. Currently charts are plotted from a min_cases date starting point. Different countries have different length histories. Could we also have an option to plot using simple calendar dates and showing the date on the chart? Thank you
So, using the code you suggested in your original post, this is what happens:
> remotes::install_github("joachim-gassen/tidycovid19")
Downloading GitHub repo joachim-gassen/tidycovid19@master
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?
1: All
2: CRAN packages only
3: None
4: Rcpp (1.0.4 -> 1.0.4.6) [CRAN]
5: isoband (0.2.0 -> 0.2.1 ) [CRAN]
Enter one or more numbers, or an empty line to skip updates:
1
countrycode (NA -> 1.1.1 ) [CRAN]
gtrendsR (NA -> 1.4.4 ) [CRAN]
shinyWidgets (NA -> 0.5.1 ) [CRAN]
rclipboard (NA -> 0.1.2 ) [CRAN]
Rcpp (1.0.4 -> 1.0.4.6) [CRAN]
isoband (0.2.0 -> 0.2.1 ) [CRAN]
anytime (NA -> 0.3.7 ) [CRAN]
Installing 7 packages: countrycode, gtrendsR, shinyWidgets, rclipboard, Rcpp, isoband, anytime
Error: Failed to install 'tidycovid19' from GitHub:
(converted from warning) unable to access index for repository https://joachim-gassen.github.io/drat/src/contrib:
cannot open URL 'https://joachim-gassen.github.io/drat/src/contrib/PACKAGES'
I then tried with devtools::install_github("joachim-gassen/tidycovid19") and got a similare response:
> install_github("joachim-gassen/tidycovid19")
Downloading GitHub repo joachim-gassen/tidycovid19@master
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?
1: All
2: CRAN packages only
3: None
4: Rcpp (1.0.4 -> 1.0.4.6) [CRAN]
5: isoband (0.2.0 -> 0.2.1 ) [CRAN]
Enter one or more numbers, or an empty line to skip updates:
2
countrycode (NA -> 1.1.1 ) [CRAN]
gtrendsR (NA -> 1.4.4 ) [CRAN]
shinyWidgets (NA -> 0.5.1 ) [CRAN]
rclipboard (NA -> 0.1.2 ) [CRAN]
Rcpp (1.0.4 -> 1.0.4.6) [CRAN]
isoband (0.2.0 -> 0.2.1 ) [CRAN]
anytime (NA -> 0.3.7 ) [CRAN]
Installing 7 packages: countrycode, gtrendsR, shinyWidgets, rclipboard, Rcpp, isoband, anytime
Error: Failed to install 'tidycovid19' from GitHub:
(converted from warning) unable to access index for repository https://joachim-gassen.github.io/drat/src/contrib:
cannot open URL 'https://joachim-gassen.github.io/drat/src/contrib/PACKAGES'
It was only afer theis that I tried using the drat package as it allows setting up a link to the drat repository and easy installation when running scripts where you want to update data. The syntax used was:
library(drat)
addRepo("joachim-gassen")
install.packages("tidycovid19")
This resulted in:
Warning in install.packages :
unable to access index for repository https://joachim-gassen.github.io/drat/src/contrib:
cannot open URL 'https://joachim-gassen.github.io/drat/src/contrib/PACKAGES'
Warning in install.packages :
unable to access index for repository https://joachim-gassen.github.io/drat/src/contrib:
cannot open URL 'https://joachim-gassen.github.io/drat/src/contrib/PACKAGES'
Warning in install.packages :
package ‘tidycovid19’ is not available (for R version 3.6.3)
Warning in install.packages :
unable to access index for repository https://joachim-gassen.github.io/drat/bin/macosx/el-capitan/contrib/3.6:
cannot open URL 'https://joachim-gassen.github.io/drat/bin/macosx/el-capitan/contrib/3.6/PACKAGES'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.