Skip to content

Instantly share code, notes, and snippets.

@dholstius
Last active Aug 29, 2015
Embed
What would you like to do?
Import records from a DustTrak log
read_dusttrak <- function(
file,
header_rows = 18
) {
header <- read.csv(file, nrow = header_rows, header = FALSE, stringsAsFactors = FALSE)
header <- as.list(setNames(header$V2, header$V1))
records <- read.csv(file, skip = header_rows + 1, header = TRUE, stringsAsFactors = FALSE)
names(records) <- c("elapsed", "value", "alarm", "error")
start_mdYHMSp <- with(header, paste(`Test Start Date`, `Test Start Time`))
records <- data.frame(start = mdy_hms(start_mdYHMSp) + records$elapsed,
mutate(records, value = as.integer(value * 1000))) # as ug/m3
attr(records, "header") <- header
return(records)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment