Introduction

library("knitr")
library("dplyr")

This package aims at supporting the analysis of PM2.5 measures made with RTI MicroPEM. RTI MicroPEM are personal monitoring devices (PM2.5 and PM10) developed by RTI international.

The goal of the package functions is to help in two main tasks:

For the examination of individual files, the package provides a function for transforming the output of a RTI MicroPEM into an object of a R6 class called micropem, functions for examining this information in order to look for possible problems in the data. The package moreover provides a Shiny app used for the field work of the CHAI project, but that could easily be adapted to other contexts.

This document aims at providing an overview of the functionalities of the package.

Checking individual files: from input data to micropem objects

The MicroPEM device outputs a csv file with all the information about the measures, depending on the options chosen in RTI MicroPEM software when uploading data, for instance:

Therefore, the micropem package offers a R6 class called micropem for storing the information, that will be easier to use by other functions. The class has fields with measures over time and a field that is a list containing all the information located at the top of the MicroPEM output file, called settings. Here is a picture of a RTI MicroPEM output file showing how the information is stored in the R6 class.

alt text

Fields

settings field

This field is a data.frame (dplyr tbl_df) that includes 41 variables.

measures field

This field is a data.frame (dplyr tbl_df) with the time-varying variables.

filename field

This field contains the full filename of the file that was used to generate the micropem object.

The convert_output function.

The convert_output only takes one arguments as input: the path to the output file. The result of a call to this function is an object of the class micropem. Below is a example of a call to convert_output followed by a call to the print method.

library("rtimicropem")
micropem_example <- convert_output(system.file("extdata", "CHAI.csv", package = "rtimicropem"))
class(micropem_example)
print(micropem_example)

Visualizing information contained in a micropem object

Plot method

The R6 micropem class has its own plot method. It allows to draw a plot of all time-varying measures against the timeDate field. It takes two arguments: the micropem object to be plotted, and the type of plots to be produced, either a "plain" ggplot2 plot with 6 facets, or its interactive version produced with the rbokeh package -- the corresponding values of type are respectively "plain" and "interactive".

Below we show to examples of uses of the plot method on a micropem object.

This is a "plain" plot.

data("micropemChai")
micropemChai$plot()

The code below would produce an interactive representation: the y-value is displayed when mouse is over each point. It is intended to be used as quick visualization tool as well, not as a plot method for putting a nice figure in a paper.

library("rbokeh")
p <- micropemChai$plot(type = "interactive")
p

summary method

Plotting the micropem object is already a good way to notice any problem. Another methods aims at providing more compact information about the time-varying measures. It is called summary and outputs a table with summary statistics for each time-varying measures, except time.

Below is an example of use of this method.

library("xtable")
data("micropemChai")
results <- micropemChai$summary()
results %>% knitr::kable()

Shiny app developed for the CHAI project

In the context of the CHAI project, we developed a Shiny app based on the previous functions, that allows to explore a MicroPEM output file. The app is called by the function run_shiny_app with no argument. There is one side panel where one can choose the file to analyse. There are four tabs:

This app allows the exploration of a MicroPEM output file with no R experience.

Below we show screenshots of the app.

From a bunch of output files to data ready for further analysis

The batch_convert function allows to convert a set of MicroPEM output files into two csv files, one containing the settings, one containing the measures, in each case with a filename column representing the full filename of the original file.

These csv files can then be used for transformation by device ID for instance, or for analysis by date, or by participant ID of a study if the participant ID is contained in the filename or in the initial MicroPEM output files. The csv file with all the settings of all MicroPEM output files can help checking whether the different monitoring sessions were done in similar conditions.



maelle/rtimicropem documentation built on May 16, 2022, 9:34 p.m.