knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

library(comotext)

comotext: R Tools to Extract COVID-19-Related Resolutions and Policies in the Philippines

Lifecycle: experimental Travis build status AppVeyor build status R build status Codecov test coverage DOI

To assess possible impact of various COVID-19 prediction models on Philippine government response, text from various resolutions, press releases and legislation has been collected using data mining approaches implemented in R. This package includes functions used for this data mining process and datasets of text that have been collected and processed for use in text analysis.

Installation

comotext is still in active development. You can install the development version of comotext from GitHub with:

if(!require(remotes)) install.packages("remotes")
remotes::install_github("como-ph/comotext")

Usage

Datasets

comotext currently has 28 datasets of COVID-19-related resolutions and policies in the Philippines. These datasets are 28 resolutions made by the Inter-Agency Task Force for the Management of Emerging Infectious Diseases (IATF).

A description of the available datasets can be found here.

A table of the r nrow(iatfLinks) IATF resolutions and the URLs to download them can be generated using the function get_iatf_links() as follows:

get_iatf_links()

comotext also holds 1 dataset of all Department of Health press releases to date. A description of the dohRelease dataset can be found here. This dataset has been generated using the get_doh_release() function (see description below) included in comotext. Related to this is the dataset dohLinks which holds the relative URL links for each of the press releases in the Department of Health website to date. This dataset has been produced using the get_doh_links() function (see description below) included in comotext. A description of the dohLinks dataset can be found here.

Extracting text data from press releases

Press releases issued by the Department of Health are available publicly via their website. The structure of the press releases page is that the section with the links to the press releases text is in a panel within the web page with the panel itself having pagination with each page containing links to 28 press releases with press releases ordered in reverse chronological order.

The function get_doh_links() extracts the relative URL links to each of the press releases on a current page within the press releases panel. If we want to get the absolute URL links for the press releases on page 1 of the press releases panel, we use:

get_doh_links(pages = 1)

The function get_doh_release() creates a dataset of text of press releases given a URL of a specific press release text and the date of release. This information is provided for by get_doh_links(). If we want to get the text data of the press releases from page 1 of the press release panel, we use:

## Extract URLs from DoH press releases page 1
prURL <- get_doh_links(pages = 1)

## Extract text from first press release
get_doh_release(df = prURL[1, ])

To get all the DoH press releases available from their website, use:

## Extract URLs
pr <- get_doh_links(pages = 1:25)

## Extract all press releases text
pressRelease <- NULL

for(i in 1:nrow(pr)) {
  currentPR <- get_doh_release(df = pr[i, ])

  pressRelease <- rbind(pressRelease, currentPR)
}
dohRelease

This produces the same dataset as dohRelease included in comotext.

Concatenating text datasets

The datasets described above can be processed and analysed on their own or as a combined corpus of text data. comotext provides convenience functions that concatenates all or specific text datasets available from the comotext package.

Concatenating datasets based on a specific search term

The combine_docs function allows the user to specify search terms to use in identifying datasets provided by the comotext package. The docs argument allows the specification of a vector of search terms to use to identify the names of datasets to concatenate. If the name/s of the datasets contain these search terms, the datasets with these name/s will be returned.

combine_docs(docs = "resolution")

The combine_iatf function is a specialised wrapper of the combine_docs function that specifically returns datasets containing IATF resolutions. An additional argument res allows users to specify which IATF resolutions to return. To get IATF resolution 10, 11, and 12, the following call to combine_iatf is made as follows:

combine_iatf(docs = "resolution", res = 10:12)

To check if only resolutions 10 to 12 have been returned:

combine_iatf(docs = "resolution", res = 10:12)[ , c("type", "id")]


como-ph/comotext documentation built on May 24, 2020, 8:28 p.m.