diff --git a/R/data.R b/R/data.R index f6f99c0..b4fe920 100644 --- a/R/data.R +++ b/R/data.R @@ -24,7 +24,7 @@ #' @source The data set was derived from #' and published by \insertCite{Hodgkins.2018;textual}{ir} under the CC BY 4.0 license . #' \insertCite{Hodgkins.2018;textual}{ir} originally derived the data on Klason Lignin and Holocellulose content from -#' \insertCite{LaCruz.2016;textual}{ir} . +#' \insertCite{LaCruz.2016;textual}{ir}. #' #' @references #' \insertAllCited{} diff --git a/R/ir.R b/R/ir.R index c62551e..c82d702 100644 --- a/R/ir.R +++ b/R/ir.R @@ -326,7 +326,7 @@ ir_reclass_ir <- function(x) { if(! "spectra" %in% colnames(x)) { # spectra column not present structure(x, class = setdiff(class(x), "ir")) - } else if(class(try(ir_check_spectra(x$spectra), silent = TRUE)) == "try-error") { # spectra column present, but wrong format + } else if(inherits(try(ir_check_spectra(x$spectra), silent = TRUE), "try-error")) { # spectra column present, but wrong format structure(x, class = setdiff(class(x), "ir")) } else { # spectra column with correct format present structure(x, class = c("ir", setdiff(class(x), "ir"))) diff --git a/R/ir_bc.R b/R/ir_bc.R index db64910..e99a104 100644 --- a/R/ir_bc.R +++ b/R/ir_bc.R @@ -29,24 +29,30 @@ #' `return_bl = TRUE`, the baselines instead of the spectra in column `spectra`. #' #' @examples +#' library(dplyr) +#' #' # rubberband baseline correction #' x1 <- #' ir::ir_sample_data %>% +#' dplyr::slice(1:10) %>% #' ir::ir_bc(method = "rubberband") #' #' # polynomial baseline correction #' x2 <- #' ir::ir_sample_data %>% +#' dplyr::slice(1:10) %>% #' ir::ir_bc(method = "polynomial", degree = 2) #' #' # Savitzky-Golay baseline correction #' x3 <- #' ir::ir_sample_data %>% +#' dplyr::slice(1:10) %>% #' ir::ir_bc(method = "sg", p = 3, n = 199, ts = 1, m = 0) #' #' # return the baseline instead of the baseline corrected spectra #' x1_bl <- #' ir::ir_sample_data %>% +#' dplyr::slice(1:10) %>% #' ir::ir_bc(method = "rubberband", return_bl = TRUE) #' #' @export diff --git a/man/ir_bc.Rd b/man/ir_bc.Rd index 79912ef..1e4bd15 100644 --- a/man/ir_bc.Rd +++ b/man/ir_bc.Rd @@ -36,24 +36,30 @@ using a rubberband function that is fitted to each spectrum (see the input spectra (see \code{\link[=ir_bc_sg]{ir_bc_sg()}}). } \examples{ +library(dplyr) + # rubberband baseline correction x1 <- ir::ir_sample_data \%>\% + dplyr::slice(1:10) \%>\% ir::ir_bc(method = "rubberband") # polynomial baseline correction x2 <- ir::ir_sample_data \%>\% + dplyr::slice(1:10) \%>\% ir::ir_bc(method = "polynomial", degree = 2) # Savitzky-Golay baseline correction x3 <- ir::ir_sample_data \%>\% + dplyr::slice(1:10) \%>\% ir::ir_bc(method = "sg", p = 3, n = 199, ts = 1, m = 0) # return the baseline instead of the baseline corrected spectra x1_bl <- ir::ir_sample_data \%>\% + dplyr::slice(1:10) \%>\% ir::ir_bc(method = "rubberband", return_bl = TRUE) } diff --git a/man/ir_sample_data.Rd b/man/ir_sample_data.Rd index e5612af..d067883 100644 --- a/man/ir_sample_data.Rd +++ b/man/ir_sample_data.Rd @@ -25,7 +25,7 @@ holocellulose in each sample.} The data set was derived from \url{https://www.nature.com/articles/s41467-018-06050-2} and published by \insertCite{Hodgkins.2018;textual}{ir} under the CC BY 4.0 license \url{https://creativecommons.org/licenses/by/4.0/}. \insertCite{Hodgkins.2018;textual}{ir} originally derived the data on Klason Lignin and Holocellulose content from -\insertCite{LaCruz.2016;textual}{ir} \url{https://doi.org/10.1089/ees.2014.0402}. +\insertCite{LaCruz.2016;textual}{ir}. } \usage{ ir_sample_data