manage_na {OpenSpecy} | R Documentation |
Ignore or remove NA intensities
Description
Sometimes you want to keep or remove NA values in intensities to allow for spectra with varying shapes to be analyzed together or maintained in a single Open Specy object.
Usage
manage_na(x, ...)
## Default S3 method:
manage_na(x, lead_tail_only = TRUE, ig = c(NA), ...)
## S3 method for class 'OpenSpecy'
manage_na(x, lead_tail_only = TRUE, ig = c(NA), fun, type = "ignore", ...)
Arguments
x |
a numeric vector or an R OpenSpecy object. |
lead_tail_only |
logical whether to only look at leading adn tailing values. |
ig |
character vector, values to ignore. |
fun |
the name of the function you want run, this is only used if the "ignore" type is chosen. |
type |
character of either "ignore" or "remove". |
... |
further arguments passed to |
Value
manage_na()
return logical vectors of NA locations (if vector provided) or an
OpenSpecy
object with ignored or removed NA values.
Author(s)
Win Cowger, Zacharias Steinmetz
See Also
OpenSpecy
object to be matched with a reference library
fill_spec()
can be used to fill NA values in Open Specy objects.
restrict_range()
can be used to restrict spectral ranges in other ways than removing NAs.
Examples
manage_na(c(NA, -1, NA, 1, 10))
manage_na(c(NA, -1, NA, 1, 10), lead_tail_only = FALSE)
manage_na(c(NA, 0, NA, 1, 10), lead_tail_only = FALSE, ig = c(NA,0))
data(raman_hdpe)
raman_hdpe$spectra[[1]][1:10] <- NA
#would normally return all NA without na.rm = TRUE but doesn't here.
manage_na(raman_hdpe, fun = make_rel)
#will remove the first 10 values we set to NA
manage_na(raman_hdpe, type = "remove")