Skip to content

Commit

Permalink
small example fix
Browse files Browse the repository at this point in the history
  • Loading branch information
philouail committed Feb 15, 2024
1 parent 3a8d3a9 commit 255c2fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions R/Spectra.R
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ NULL
#' ## in `spectraData`.
#' spectraVariables <- c("rtime", "precursorMz", "peaksCount")
#' ranges <- c(30, 350, 200,500, 350, 600)
#' filt_spectra <- filterRanges(data, spectraVariables = spectraVariables,
#' filt_spectra <- filterRanges(sciex, spectraVariables = spectraVariables,
#' ranges = ranges)
#'
#' ## ---- DATA MANIPULATIONS AND OTHER OPERATIONS ----
Expand Down Expand Up @@ -2424,10 +2424,11 @@ setMethod("filterRanges", "Spectra",
if (length(spectraVariables) != length(ranges) / 2)
stop("Length of 'spectraVariables' must be half the length ",
"of 'ranges'")
if (is.character(spectraVariables))
if (is.character(spectraVariables)){
if(!all(spectraVariables %in% spectraVariables(object)))
stop("'spectraVariables' need to correspond to colnames of",
"the 'spectraData' of the object")
stop("'spectraVariables' need to correspond to colnames of",
"the 'spectraData' of the object")
}
query <- spectraData(object)[, spectraVariables]
nc <- ncol(query)

Expand Down
2 changes: 1 addition & 1 deletion man/Spectra.Rd

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

0 comments on commit 255c2fd

Please sign in to comment.