Skip to content

Commit

Permalink
Minor tweaks for lintr dev version
Browse files Browse the repository at this point in the history
  • Loading branch information
Bisaloo committed Jun 22, 2024
1 parent 5c7fbad commit 269c947
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 34 deletions.
4 changes: 2 additions & 2 deletions R/convert_tocsv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
Expand All @@ -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
)
}
Expand Down
4 changes: 2 additions & 2 deletions R/get_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
Expand All @@ -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
)

Expand Down
4 changes: 2 additions & 2 deletions R/get_spec.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
)
Expand All @@ -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
)

Expand Down
12 changes: 6 additions & 6 deletions R/parse_avantes_binary.R
Original file line number Diff line number Diff line change
Expand Up @@ -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_
)
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
10 changes: 5 additions & 5 deletions R/parse_avantes_converted.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
14 changes: 7 additions & 7 deletions R/parse_generic.R
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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))
}
2 changes: 1 addition & 1 deletion R/parse_jdx.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))

}
10 changes: 5 additions & 5 deletions R/parse_oceanoptics_converted.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
2 changes: 1 addition & 1 deletion R/parse_procspec.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
6 changes: 3 additions & 3 deletions R/parse_spc.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 269c947

Please sign in to comment.