Skip to content

Commit

Permalink
fix (read_chromeleon): revert bad change in attach_metadata arguments
Browse files Browse the repository at this point in the history
add whitespace
  • Loading branch information
ethanbass committed Aug 17, 2023
1 parent 1ea82be commit 240d3a8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions R/attach_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ attach_metadata <- function(x, meta, format_in, format_out, data_format, parser
parser = "chromConverter",
format_out = format_out)
}, "chromeleon" = {
datetime.idx <- unlist(sapply(c("Date$","Time$"), function(str) grep(str, names(meta))))
datetime.idx <- unlist(sapply(c("Date$", "Time$"), function(str) grep(str, names(meta))))
datetime <- unlist(meta[datetime.idx])
if (length(datetime > 1)){
datetime <- paste(datetime, collapse=" ")
datetime <- paste(datetime, collapse = " ")
}
datetime <- as.POSIXct(datetime, format = c("%m/%d/%Y %H:%M:%S", "%d.%m.%Y %H:%M:%S",
"%m/%d/%Y %H:%M:%S %p %z"))
Expand Down
3 changes: 1 addition & 2 deletions R/parsers.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ read_chromeleon <- function(file, format_out = c("matrix","data.frame"),
meta <- lapply(meta, function(x) gsub(",",".",x))
}
if (!inherits(meta, "try-error")){
x <- attach_metadata(x, meta, format_in = "chromeleon",
metadata_format = metadata_format,
x <- attach_metadata(x, meta, format_in = metadata_format,
format_out = format_out, data_format = data_format,
parser = "chromConverter", source_file = file)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-extra.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ test_that("read_chroms can read 'Chromeleon' comma-separated files", {
skip_on_cran()
skip_if_not_installed("chromConverterExtraTests")
path <- system.file("chromeleon_comma.txt", package = "chromConverterExtraTests")
x <- read_chroms(path, format_in = "chromeleon", progress_bar = FALSE)
x <- read_chroms(path, format_in = "chromeleon_uv", progress_bar = FALSE)
expect_equal(class(x[[1]])[1], "matrix")
expect_equal(dim(x[[1]]), c(3241, 1))
expect_equal(attr(x[[1]], "parser"), "chromConverter")
Expand Down

0 comments on commit 240d3a8

Please sign in to comment.