knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(covid19BFI)
library(dplyr)

covid19BFI

The R package covid19BFI is a container for the "Covid19: The Battle of Independence"" which is an application that has been built as an interactive comparative tool for the analysis over the impact and response to corona virus between Ireland and the United Kingdom. As detailed in the "About" section, there is a long standing and divisive history of conflict and war between the two countries that stems from Ireland's plight for seeking their complete independence from the United Kingdom. Corona virus has presented pundits who are pro independence with a case study to further ignite and push the fight for independence, with the difference in impact and response between Ireland and the United Kingdom acting as a proxy for Ireland's ability to stand completely independent, with this package providing access to the application that hands the user the data and the tools to make critically assess the responses between the two countries as well, as access the data and other tools to recreate the analysis.

Launching the Covid19: The Battle for Independence application

The application can be accessed by using the launch_app( ) function provided by the covid19BFI package. When run, launch_app will build and generate the Covid19: The Battle for Independence application.

What Covid19: The Battle for Independence application provides

The application has been built as an interactive comparative tool to assess the different impact and response that Ireland and the United Kingdom (GBR) have taken with regards to dealing with covid19. This application provides four web pages that the user can navigate across by accessing the navigation bar that can be found along the top border of the app. The navigation bar list four separate sections, they are:

  1. About
  2. Cases, Deaths and Government Intervention
  3. Movement Analysis
  4. References and acknowledgements

The analysis that can be found in the individual sections, and their interactive features, are detailed below:

Feature of covid19BFI package

Available datasets

covid19BFI package provides three datasets that were used in producing the analysis in the Covid19: The Battle for Independence application and can be directly accessed by printing their names once covid19BFI is installed and loaded. The datasets are as follows:

  1. covid_data_uk_irl: Which is the final dataset that was used to perform the analysis, consisting of the variables listed under the Cases Deaths and Government Intervention section.
  2. raw_covid_data_uk_url: The raw dataset which is a combination of data sourced from from tidycovid19 package and the covdata.
  3. mobility_major_cities: The data set used to conduct the mobility analysis comparison between IRL and UK. This contains the change in mobility across walking, driving and transit for all the major cities of Ireland the United Kingdom.

Suppose we wanted to see the covid data between two specific dates we could use the filter function and filter the dates from a specific date, could access the datasets as follows.

covid_data_uk_irl %>%
  arrange(desc(date)) %>%
  head(n = 10)

Datatable styling

A datatable styling function called dt_styler is provided by covid19BFI package that allows the user to color the rows of a datatable according to two key variables that are found in the index column of the chosen dataset. dt_styler takes the following 8 arguments:

  1. data: A data frame that contains the data to be output in the datatable.
  2. id: The column name that contains the key variables and will be used as an index for the function to identify.
  3. key1: A single argument that is the first key variable that is chosen to have each of its rows highlighted by being colored in the chosen color.
  4. key2: A single argument that is the second key variable that is chosen to have each of its rows highlighted by being colored in the other chosen color.
  5. clr1: The first color that will highlight all the rows that are associated with key1.
  6. clr2: The *second color that will highlight all the rows that are associated with key1.
  7. plength: The argument the specifies the number of rows to be displayed in the table on the first page. Can take up to any number between 1 and the maximum length of the dataset.
  8. rownames: Will create the first column as an index with the row numbers for each row when set to TRUE, rownames will not be shown when set to FALSE.

As stated any two variables can have their rows uniquely colored in any two chosen colors with the two key variables requiring to exist in the index column, within an interactive datatable. The datatable drop down page length is fixed at 7, 10, 15, 20 however the first page can be overwritten by using stating the desired page length using the plength argument. In the event we wished to highlight the rows in table to make sure it was clear what data belonged to which variable, the dt_styler function could be used, for example if you wanted to highlight the sepal length of two different bird we could do as follows.

dt <- iris %>% 
  filter(Species %in% c("setosa", "versicolor"),
         Sepal.Length >= 4.8 & Sepal.Length <= 5.0) %>%
  arrange(Sepal.Length)
#Builds a datatable of length 10, with the rows for setosa being colored blueand the rows for versicolor colored red.
dt_styler(dt, "Species", "setosa", "versicolor", "#baf4f0", "#f4e3ba", 10, rownames = FALSE) 

More details



etc5523-2020/r-package-assessment-samuellyu-2021 documentation built on Jan. 1, 2021, 1:13 a.m.