\name{extractSpectra-methods} \docType{methods} \alias{extractSpectra-methods} \alias{extractSpectra} \title{ Extracts a set of spectra from an 'MSnExp' object } \description{ Extracts the spectra defined by the \code{selected} parameter and returns a subset \code{"\linkS4class{MSnExp}"} instance. The \code{featureData} slot is also subset accordingly. Note that values in \code{selected} are recycled if shorter than \code{length(MSnExp)}. This method is equivalent as using the \code{[} operator. } \section{Methods}{ \describe{ \item{\code{signature(object = "MSnExp", selected = "logical")}}{ Returns an \code{"\linkS4class{MSnExp}"} object containing spectra defined by the logical \code{selected} argument. } } } \author{ Laurent Gatto } \seealso{ \code{\link{extractPrecSpectra}} } \examples{ fn <- dir(system.file(package = "MSnbase", dir = "extdata"), full.names = TRUE, pattern = "mzXML$") aa <- readMSData(fn, verbose=FALSE) sel <- rep(FALSE, length(aa)) sel[1:3] <- TRUE bb <- extractSpectra(aa, sel) stopifnot(length(bb) == sum(sel)) processingData(bb) ## equivalent cc <- aa[sel] all(featureNames(cc) == featureNames(bb)) } \keyword{methods}