covid19italy v0.3.0 is now on CRAN

[This article was first published on Rami Krispin, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.




Version 0.3.0 of the covid19italy is now available on CRAN. The package provides a daily snapshot of the covid19 cases in Italy by province, region and national levels. While the data on the package is getting refreshed once every few months, the update_data function enables you to get the most recent data available on the Github version (updated on a daily basis).

Additional resources:

Key changes

The main updates in v0.3.0 related to changes in the data structure:

  • Updates for the italy_total dataset:
    • Added positive_clinical_activity – positive cases emerged from clinical activity
    • Added positive_surveys_tests – positive cases emerging from surveys and tests planned at the national level
  • Updates for the italy_region dataset:
    • Added positive_clinical_activity – positive cases emerged from clinical activity
    • Added positive_surveys_tests – positive cases emerging from surveys and tests planned at the regional level

In addition, updates of the CI/CD of the package data refresh automation:

Refresh the data

As the data on the Github version is getting updated on a daily basis, the update_data function enables to keep the data updated on the installed version. The function compared the data available on the installed version with the ones on the Github version, when new data is available, it will reinstall the package from Github. For example:

library(covid19italy)

data("italy_total")

max(italy_total$date)

[1] "2020-07-20"

update_data()
Updates are available on the covid19italy Dev version, do you want to update? n/Y y

These packages have more recent versions available.

The data was refresed, please restart your session to have the new data available

After restarting the R session, the new data is available for use:

library(covid19italy)

data("italy_total")

max(italy_total$date)

## [1] "2020-07-27"

Visualize the distribution of the cases

The italy_total dataset provides a snapshot for the national daily cases distribution. That includes:

  • Overall cases distribution:
    • Active
    • Recovered
    • Death
  • Active cases distribution:
    • Intensive care
    • Hospitalized with symptoms
    • Home Confinement

In the following examples, we will use plotly to visualize those distributions over time. Start with the general distribution of the cases:

library(plotly)

plot_ly(data = italy_total,
        x = ~ date,
        y = ~ cumulative_positive_cases, 
        name = 'Active', 
        fillcolor = '#1f77b4',
        type = 'scatter',
        mode = 'none', 
        stackgroup = 'one') %>%
  add_trace( y = ~ death, 
             name = "Death",
             fillcolor = '#E41317') %>%
  add_trace(y = ~recovered, 
            name = 'Recovered', 
            fillcolor = 'forestgreen') %>%
  layout(title = "Italy - Distribution of Covid19 Cases",
         legend = list(x = 0.1, y = 0.9),
         yaxis = list(title = "Number of Cases"),
         xaxis = list(title = "Source: Italy Department of Civil Protection"))

And below is the distribution of the active cases:

plot_ly(data = italy_total,
        x = ~ date,
        y = ~home_confinement, 
        name = 'Home Confinement', 
        fillcolor = '#FDBBBC',
        type = 'scatter',
        mode = 'none', 
        stackgroup = 'one') %>%
  add_trace( y = ~ hospitalized_with_symptoms, 
             name = "Hospitalized with Symptoms",
             fillcolor = '#E41317') %>%
  add_trace(y = ~intensive_care, 
                name = 'Intensive Care', 
                fillcolor = '#9E0003') %>%
  layout(title = "Italy - Distribution of Active Covid19 Cases",
         legend = list(x = 0.8, y = 0.9),
         yaxis = list(title = "Number of Cases"),
         xaxis = list(title = "Source: Italy Department of Civil Protection"))

Roadmap

The main goal for the next CRAN version release is to adopt the Covid19R project data format standard and add it to the covid19r package.

To leave a comment for the author, please follow the link and comment on their blog: Rami Krispin.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)