Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dholstius
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dholstius/ba793d1af5b87784996b to your computer and use it in GitHub Desktop.
Save dholstius/ba793d1af5b87784996b to your computer and use it in GitHub Desktop.
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