knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(covid19BFI) library(dplyr)
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.
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.
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:
The analysis that can be found in the individual sections, and their interactive features, are detailed below:
About: Contains information regarding purpose and basis behind the application as well as information regarding the creator of the application.
Cases Deaths and Government Intervention: Contains an interactive comparative analysis on the each of the following statistics:
With following interactive elements:
The page displays an interactive figure visualizing the selected counts that have been chosen for comparison between the two nations and a table comparing the different number of measures used by each government across the dates they were implemented. Furthermore, an interactive table is presented which provides a grouped monthly percentage breakdown across the number of measures, restrictions and policies enacted by both Ireland and United Kingdom for the following three types of government intervention:
Number of social distance measures
Number of introduced public health policies
Here the user can you navigate across the percentage breakdown of the three types of government intervention by accessing tabs that are situated below the the heading "Government intervention" for both countries, with the United Kingdom (GBR) colored red and Ireland colored in green.
Movement Analysis: This page provides an analysis on the impact of covid19 has had on the mobility of residents of the major cities in both Ireland and the United Kingdom. The page displays a map of both Ireland and the United Kingdom with the major cities highlights and figure displaying the movement trends of residents in the following three forms of transport:
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:
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.raw_covid_data_uk_url
: The raw dataset which is a combination of data sourced from from tidycovid19 package and the covdata.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)
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:
data
: A data frame that contains the data to be output in the datatable.id
: The column name that contains the key variables and will be used as an index for the function to identify.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.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.clr1
: The first color that will highlight all the rows that are associated with key1.clr2
: The *second color that will highlight all the rows that are associated with key1.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.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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.