From 269c947dbcd037fbffc2686605045fc767380d44 Mon Sep 17 00:00:00 2001 From: Hugo Gruson <10783929+Bisaloo@users.noreply.github.com> Date: Sat, 22 Jun 2024 14:08:54 +0200 Subject: [PATCH] Minor tweaks for lintr dev version --- R/convert_tocsv.R | 4 ++-- R/get_metadata.R | 4 ++-- R/get_spec.R | 4 ++-- R/parse_avantes_binary.R | 12 ++++++------ R/parse_avantes_converted.R | 10 +++++----- R/parse_generic.R | 14 +++++++------- R/parse_jdx.R | 2 +- R/parse_oceanoptics_converted.R | 10 +++++----- R/parse_procspec.R | 2 +- R/parse_spc.R | 6 +++--- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/R/convert_tocsv.R b/R/convert_tocsv.R index 1cc1aa0..5c4cf43 100644 --- a/R/convert_tocsv.R +++ b/R/convert_tocsv.R @@ -63,7 +63,7 @@ lr_convert_tocsv <- function(where = NULL, ext = "txt", decimal = ".", overwrite = overwrite, metadata = metadata ), error = function(e) { - warning(conditionMessage(e)) + warning(conditionMessage(e), call. = FALSE) return(NULL) }) }) @@ -81,7 +81,7 @@ lr_convert_tocsv <- function(where = NULL, ext = "txt", decimal = ".", warning( "Could not import one or more files:\n", - paste0(files[whichfailed], collapse = "\n"), + paste(files[whichfailed], collapse = "\n"), call. = FALSE ) } diff --git a/R/get_metadata.R b/R/get_metadata.R index ac7f032..5d4bf87 100644 --- a/R/get_metadata.R +++ b/R/get_metadata.R @@ -88,7 +88,7 @@ lr_get_metadata <- function(where = getwd(), ext = "ProcSpec", sep = NULL, tryCatch( gmd(x), error = function(e) { - warning(conditionMessage(e)) + warning(conditionMessage(e), call. = FALSE) return(NULL) }) }) @@ -104,7 +104,7 @@ lr_get_metadata <- function(where = getwd(), ext = "ProcSpec", sep = NULL, warning( "Could not import one or more files:\n", - paste0(files[whichfailed], collapse = "\n"), + paste(files[whichfailed], collapse = "\n"), call. = FALSE ) diff --git a/R/get_spec.R b/R/get_spec.R index 5a94f94..e70d025 100644 --- a/R/get_spec.R +++ b/R/get_spec.R @@ -113,7 +113,7 @@ lr_get_spec <- function(where = getwd(), ext = "txt", lim = c(300, 700), tryCatch( gsp(x), error = function(e) { - warning(conditionMessage(e)) + warning(conditionMessage(e), call. = FALSE) return(NULL) } ) @@ -129,7 +129,7 @@ lr_get_spec <- function(where = getwd(), ext = "txt", lim = c(300, 700), } else if (length(whichfailed) > 0) { warning("Could not import one or more files:\n", - paste0(files[whichfailed], collapse = "\n"), + paste(files[whichfailed], collapse = "\n"), call. = FALSE ) diff --git a/R/parse_avantes_binary.R b/R/parse_avantes_binary.R index 101a2c4..b168ec0 100644 --- a/R/parse_avantes_binary.R +++ b/R/parse_avantes_binary.R @@ -103,9 +103,9 @@ lr_parse_trm <- function(filename) { c("scope", "white", "dark")) } else {# scope mode data <- data.frame( - "scope" = readBin(f, "numeric", ipixlast - ipixfirst + 1, 4, endian = "little"), - "white" = NA_real_, - "dark" = NA_real_ + scope = readBin(f, "numeric", ipixlast - ipixfirst + 1, 4, endian = "little"), + white = NA_real_, + dark = NA_real_ ) } @@ -142,7 +142,7 @@ lr_parse_trm <- function(filename) { dark_average, white_average, scope_average, dark_boxcar, white_boxcar, scope_boxcar) - return(list("data" = data, "metadata" = metadata)) + return(list(data = data, metadata = metadata)) } #' @rdname lr_parse_trm @@ -302,9 +302,9 @@ lr_parse_rfl8 <- function(filename, specnum = 1L) { mergegroup <- intToUtf8(readBin(f, "raw", n = 10, endian = "little")) - data <- as.data.frame(cbind("wl" = xcoord, + data <- as.data.frame(cbind(wl = xcoord, dark, - "white" = reference, + white = reference, scope)) data$processed <- lr_compute_processed(data) diff --git a/R/parse_avantes_converted.R b/R/parse_avantes_converted.R index c875874..beb5a1a 100644 --- a/R/parse_avantes_converted.R +++ b/R/parse_avantes_converted.R @@ -77,11 +77,11 @@ lr_parse_ttt <- function(filename) { storage.mode(data) <- "numeric" - cornames <- c("wl" = "Wave", - "dark" = "Dark", - "white" = "Ref", - "scope" = "Sample", - "processed" = "Transmittance") + cornames <- c(wl = "Wave", + dark = "Dark", + white = "Ref", + scope = "Sample", + processed = "Transmittance") data_final <- setNames( as.data.frame(matrix(NA_real_, nrow = nrow(data), ncol = 5)), diff --git a/R/parse_generic.R b/R/parse_generic.R index 14a19d5..0bde57e 100644 --- a/R/parse_generic.R +++ b/R/parse_generic.R @@ -51,7 +51,7 @@ lr_parse_generic <- function(filename, decimal = ".", sep = NULL) { - seps <- paste0(c("[[:blank:]]", sep), collapse = "|\\") + seps <- paste(c("[[:blank:]]", sep), collapse = "|\\") # Code from pavo::getspec @@ -102,13 +102,13 @@ lr_parse_generic <- function(filename, decimal = ".", sep = NULL) { metadata <- rep(NA_character_, 13) - data <- data.frame("wl" = rawsplit[, 1], - "dark" = NA_real_, - "white" = NA_real_, - "scope" = NA_real_, - "processed" = rawsplit[, dim(rawsplit)[2]]) + data <- data.frame(wl = rawsplit[, 1], + dark = NA_real_, + white = NA_real_, + scope = NA_real_, + processed = rawsplit[, dim(rawsplit)[2]]) data <- data[order(data$wl), ] - return(list("data" = data, "metadata" = metadata)) + return(list(data = data, metadata = metadata)) } diff --git a/R/parse_jdx.R b/R/parse_jdx.R index c9a42c5..1c0b20f 100644 --- a/R/parse_jdx.R +++ b/R/parse_jdx.R @@ -99,6 +99,6 @@ lr_parse_jdx <- function(filename) { data$processed <- lr_compute_processed(data) - return(list("data" = data, "metadata" = metadata)) + return(list(data = data, metadata = metadata)) } diff --git a/R/parse_oceanoptics_converted.R b/R/parse_oceanoptics_converted.R index 17d4fd0..74f2000 100644 --- a/R/parse_oceanoptics_converted.R +++ b/R/parse_oceanoptics_converted.R @@ -150,11 +150,11 @@ lr_parse_jaz <- function(filename) { } storage.mode(data) <- "numeric" - cornames <- c("wl" = "W", - "dark" = "D", - "white" = "R", - "scope" = "S", - "processed" = "P") + cornames <- c(wl = "W", + dark = "D", + white = "R", + scope = "S", + processed = "P") data_final <- setNames( as.data.frame(matrix(NA_real_, nrow = nrow(data), ncol = 5)), diff --git a/R/parse_procspec.R b/R/parse_procspec.R index a21e110..f46744c 100644 --- a/R/parse_procspec.R +++ b/R/parse_procspec.R @@ -95,5 +95,5 @@ lr_parse_procspec <- function(filename) { dark_average, white_average, scope_average, dark_boxcar, white_boxcar, scope_boxcar) - return(list("data" = as.data.frame(specdf), "metadata" = metadata)) + return(list(data = as.data.frame(specdf), metadata = metadata)) } diff --git a/R/parse_spc.R b/R/parse_spc.R index 839de7e..dcb8dfe 100644 --- a/R/parse_spc.R +++ b/R/parse_spc.R @@ -46,9 +46,9 @@ lr_parse_spc <- function(filename) { processed <- readBin(f, "numeric", n = dat_len, size = 4, endian = "little") data <- cbind(wl, - "dark" = NA_real_, - "white" = NA_real_, - "scope" = NA_real_, + dark = NA_real_, + white = NA_real_, + scope = NA_real_, processed) metadata <- rep(NA_character_, 13)