Skip to content

Commit

Permalink
allow different inputs on spec_res
Browse files Browse the repository at this point in the history
  • Loading branch information
wincowgerDEV committed Jul 25, 2023
1 parent d86a62b commit c8c383f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ S3method(share_spec,OpenSpecy)
S3method(share_spec,default)
S3method(smooth_intens,OpenSpecy)
S3method(smooth_intens,default)
S3method(spec_res,OpenSpecy)
S3method(spec_res,default)
S3method(subtr_bg,OpenSpecy)
S3method(subtr_bg,default)
S3method(write_spec,OpenSpecy)
Expand Down
25 changes: 21 additions & 4 deletions R/spec_res.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#' @rdname spec_res
#'
#' @title Spectral resolution
#'
#' @description
Expand All @@ -9,7 +11,7 @@
#' frequency difference between two lines in a spectrum that can still be
#' distinguished.
#'
#' @param x a numeric vector or an \R object which is coercible to one by
#' @param object a numeric vector or an \R object which is coercible to one by
#' \code{as.vector(x, "numeric")}; \code{x} should be \code{wavenumber} data.
#'
#' @return
Expand All @@ -18,13 +20,28 @@
#' @examples
#' data("raman_hdpe")
#' spec_res(raman_hdpe$wavenumber)
#'
#' spec_res(raman_hdpe)
#'
#' @author
#' Win Cowger, Zacharias Steinmetz
#'
#' @importFrom magrittr %>%
#' @export
spec_res <- function(x) {
(max(x) - min(x)) / length(x)
spec_res <- function(object, ...) {
UseMethod("spec_res")
}

#' @rdname spec_res
#'
#' @export
spec_res.default <- function(object, ...) {
(max(object) - min(object)) / length(object)
}

#' @rdname spec_res
#'
#' @export
spec_res.OpenSpecy <- function(object) {
spec_res.default(object$wavenumber)
}

4 changes: 4 additions & 0 deletions man/smooth_intens.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions man/spec_res.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c8c383f

Please sign in to comment.