collect_data: Single function to call when extracting variables from each...

Description Usage Arguments Details Value Examples

Description

When following the recommended use of read_monitor (data frame listing files and types, iterate with 'purrr::map2' to read), the resulting object will include a list column containing onw data frame with the data for each file (nested data).

'collect_data' processes the nested data and produces a data frame with all observations of 'date_time', 'concentration' and 'flow' from all the read files.

Additional columns should be included ad a key to identify the data from each instrument in the resulting data frame.

Usage

1
collect_data(.data, type, data_col, ...)

Arguments

.data

Dataframe containing a nested column with the data from each file. Ussually a product of iterating 'read_monitor' using 'purrr::map2'.

type

Type of monitor with which the data was recorded. Use "ecm-full" to get all variable available in the ECM files.

data_col

Column containing the nested data.

...

Additional columns present in '.data' to preserve in the output. Useful to define the key to identify each data set.

Details

Since some monitors can potentially produce files with record date/times using different date formats (e.g. d/m/y, m/d/y, y/m/d) this function tries to guess the correct format but can sometimes miss. It is recommended to provide a reference date for each file so you can check whether date/times were correctly interpreded.

There is no clear column in the UPAS files to extract the concentration data, for now this functions returns 'NA' for this concentration.

Value

A data frame with 'type', specified key columns and collected measures for 'date_time', 'concentration' and 'flow'.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
# Load required packages
library(package = "pemr")

# Define files and types. This can be any data frame, so composing data in a
# spreadsheet and reading it in works too
data_frame(
 files_col = c("path/to/file1.csv", "path/to/file2.csv"),
 types_col = c("ecm", "upas")
) %>%
mutate(
  data = map2(files_col, types_col, read_monitor)
) %>%
collect_data(
  type = types_col, data_col = data,
  files_col
)

## End(Not run)

odeleongt/pemr documentation built on May 3, 2019, 10:44 p.m.