generic_parseData: Parse generic air quality files

Description Usage Arguments Value Parsing data Creating a configList Examples

View source: R/generic_parseData.R

Description

Given a string of delimited file data, this function will parse the file as a table of data an apply some transformations and augmentations as specified by a given configuration list.

Usage

1
generic_parseData(fileString = NULL, configList = NULL)

Arguments

fileString

Character string of delimited data to parse.

configList

A R list or JSON file containing key-value pairs which affect how the parsing of fileString is handled. If configList is in JSON format, it can be passed in as a file, string, or URL.

Value

A tibble of the data contined in fileString parsed according to parameters in configList. The data is coerced into a format that is more easily convertable into a ws_monitor object at a later point.

Parsing data

Internally, this function uses read_delim to convert fileString into a tibble. If any lines of data cannot be properly parsed, and error will be thrown anf the problem lines will be printed.

Creating a configList

For more information on how to build a configList, see the Rmarkdown document "Working with Generic Data" in the localNotebooks directory.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
filePath <- system.file(
  "extdata", "generic_data_example.csv",
  package = "PWFSLSmoke",
  mustWork = TRUE
)

configPath <- system.file(
  "extdata", "generic_configList_example.json",
  package = "PWFSLSmoke",
  mustWork = TRUE
)

configList <- jsonlite::fromJSON(configPath)
fileString <- generic_downloadData(filePath)
parsedData <- generic_parseData(fileString, configList)

PWFSLSmoke documentation built on July 8, 2020, 7:19 p.m.