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:
Checking individual MicroPEM output files after, say, one day of data collection.
Building a data base based on output files, and clean and transform the data for further analysis.
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.
micropem
objectsThe 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:
the measures themselves (relative humidity corrected nephelometer),
other measures that can help interpret them or check that no problem occurred (temperature, relative humidity, battery, orifice pressure, inlet pressure, flow, accelerometer variables, reasons for shutdown, and variables related to user compliance),
a reminder of parameters set by the user (calibration parameters, frequency of measures)
and information about the device (filter ID, version of the software, etc). This is a lot of information, compiled in a handy csv format that is optimal for not losing any data along the way, but not practical for analysis.
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.
settings
fieldThis field is a data.frame (dplyr tbl_df) that includes 41 variables.
measures
fieldThis field is a data.frame (dplyr tbl_df) with the time-varying variables.
filename
fieldThis field contains the full filename of the file that was used to generate the micropem
object.
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)
micropem
objectThe 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
methodPlotting 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()
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:
One with the output of a call to the summary
method of the micropem
object created,
One with the output of a call to the chai_alarm
function that performs a few checks specific to the CHAI project,
One with the output of a call to the plot method,
One with the output of a call to summarySettings
.
This app allows the exploration of a MicroPEM output file with no R experience.
Below we show screenshots of the app.
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.