Function that returns a subset of an R object with observations corresponding to local maxima.
Usage
valleys(x, span, ignore_threshold, strict, ...)
# Default S3 method
valleys(x, span = NA, ignore_threshold = NA, strict = NA, na.rm = FALSE, ...)
# Default S3 method
valleys(x, span = NA, ignore_threshold = NA, strict = NA, na.rm = FALSE, ...)
# S3 method for class 'numeric'
valleys(x, span = 5, ignore_threshold, strict = TRUE, na.rm = FALSE, ...)
# S3 method for class 'data.frame'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
x.var.name = NULL,
y.var.name = NULL,
var.name = y.var.name,
refine.wl = FALSE,
method = "spline",
...
)
# S3 method for class 'generic_spct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
var.name = NULL,
refine.wl = FALSE,
method = "spline",
...
)
# S3 method for class 'source_spct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
unit.out = getOption("photobiology.radiation.unit", default = "energy"),
refine.wl = FALSE,
method = "spline",
...
)
# S3 method for class 'response_spct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
unit.out = getOption("photobiology.radiation.unit", default = "energy"),
refine.wl = FALSE,
method = "spline",
...
)
# S3 method for class 'filter_spct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
filter.qty = getOption("photobiology.filter.qty", default = "transmittance"),
refine.wl = FALSE,
method = "spline",
...
)
# S3 method for class 'reflector_spct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
refine.wl = FALSE,
method = "spline",
...
)
# S3 method for class 'solute_spct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
refine.wl = FALSE,
method = "spline",
...
)
# S3 method for class 'cps_spct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
var.name = "cps",
refine.wl = FALSE,
method = "spline",
...
)
# S3 method for class 'raw_spct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
var.name = "counts",
refine.wl = FALSE,
method = "spline",
...
)
# S3 method for class 'generic_mspct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
var.name = NULL,
refine.wl = FALSE,
method = "spline",
...,
.parallel = FALSE,
.paropts = NULL
)
# S3 method for class 'source_mspct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
unit.out = getOption("photobiology.radiation.unit", default = "energy"),
refine.wl = FALSE,
method = "spline",
...,
.parallel = FALSE,
.paropts = NULL
)
# S3 method for class 'response_mspct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
unit.out = getOption("photobiology.radiation.unit", default = "energy"),
refine.wl = FALSE,
method = "spline",
...,
.parallel = FALSE,
.paropts = NULL
)
# S3 method for class 'filter_mspct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
filter.qty = getOption("photobiology.filter.qty", default = "transmittance"),
refine.wl = FALSE,
method = "spline",
...,
.parallel = FALSE,
.paropts = NULL
)
# S3 method for class 'reflector_mspct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
refine.wl = FALSE,
method = "spline",
...,
.parallel = FALSE,
.paropts = NULL
)
# S3 method for class 'solute_mspct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
refine.wl = FALSE,
method = "spline",
...,
.parallel = FALSE,
.paropts = NULL
)
# S3 method for class 'cps_mspct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
var.name = "cps",
refine.wl = FALSE,
method = "spline",
...,
.parallel = FALSE,
.paropts = NULL
)
# S3 method for class 'raw_mspct'
valleys(
x,
span = 5,
ignore_threshold = 0,
strict = TRUE,
na.rm = FALSE,
var.name = "counts",
refine.wl = FALSE,
method = "spline",
...,
.parallel = FALSE,
.paropts = NULL
)
Arguments
- x
an R object
- span
integer A valley is defined as an element in a sequence which is smaller than all other elements within a window of width
span
centered at that element. UseNULL
for the global peak.- ignore_threshold
numeric Value between 0.0 and 1.0 indicating the relative size compared to tallest peak threshold below which peaks will be ignored. Negative values set a threshold so that the tallest peaks are ignored, instead of the shortest.
- strict
logical If
TRUE
, an element must be strictly greater than all other values in its window to be considered a peak.- ...
ignored
- na.rm
logical indicating whether
NA
values should be stripped before searching for peaks.- var.name, x.var.name, y.var.name
character Name of column where to look for valleys.
- refine.wl
logical Flag indicating if valley location should be refined by fitting a function.
- method
character String with the name of a method. Currently only spline interpolation is implemented.
- unit.out
character One of "energy" or "photon"
- filter.qty
character One of "transmittance" or "absorbance"
- .parallel
if TRUE, apply function in parallel, using parallel backend provided by foreach
- .paropts
a list of additional options passed into the foreach function when parallel computation is enabled. This is important if (for example) your code relies on external data or packages: use the .export and .packages arguments to supply them so that all cluster nodes have the correct environment set up for computing.
Methods (by class)
valleys(default)
: Default function usable on numeric vectors.valleys(default)
: Default returning always NA.valleys(numeric)
: Default function usable on numeric vectors.valleys(data.frame)
: Method for "data.frame" objects.valleys(generic_spct)
: Method for "generic_spct" objects.valleys(source_spct)
: Method for "source_spct" objects.valleys(response_spct)
: Method for "response_spct" objects.valleys(filter_spct)
: Method for "filter_spct" objects.valleys(reflector_spct)
: Method for "reflector_spct".valleys(solute_spct)
: Method for "solute_spct" objects.valleys(cps_spct)
: Method for "cps_spct" objects.valleys(raw_spct)
: Method for "raw_spct" objects.valleys(generic_mspct)
: Method for "generic_mspct" objects.valleys(source_mspct)
: Method for "source_mspct" objects.valleys(response_mspct)
: Method for "cps_mspct" objects.valleys(filter_mspct)
: Method for "filter_mspct" objects.valleys(reflector_mspct)
: Method for "reflector_mspct" objects.valleys(solute_mspct)
: Method for "solute_mspct" objects.valleys(cps_mspct)
: Method for "cps_mspct" objects.valleys(raw_mspct)
: Method for "raw_mspct" objects.
See also
Other peaks and valleys functions:
find_peaks()
,
find_spikes()
,
get_peaks()
,
peaks()
,
replace_bad_pixs()
,
spikes()
,
wls_at_target()
Examples
valleys(sun.spct, span = 50)
#> span increased to next odd value: 51
#> Object: source_spct [9 x 2]
#> Wavelength range 358-761 nm, step 30-72 nm
#> Label: sunlight, simulated
#> Measured on 2010-06-22 09:51:00 UTC
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI
#> Variables:
#> w.length: Wavelength [nm]
#> s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#> --
#> # A tibble: 9 × 2
#> w.length s.e.irrad
#> <dbl> <dbl>
#> 1 358 0.254
#> 2 393 0.242
#> 3 431 0.414
#> 4 487 0.651
#> 5 517 0.618
#> 6 589 0.566
#> 7 656 0.498
#> 8 719 0.337
#> 9 761 0.137
valleys(sun.spct)
#> Object: source_spct [75 x 2]
#> Wavelength range 316-796 nm, step 3-17 nm
#> Label: sunlight, simulated
#> Measured on 2010-06-22 09:51:00 UTC
#> Measured at 60.20911 N, 24.96474 E; Kumpula, Helsinki, FI
#> Variables:
#> w.length: Wavelength [nm]
#> s.e.irrad: Spectral energy irradiance [W m-2 nm-1]
#> --
#> # A tibble: 75 × 2
#> w.length s.e.irrad
#> <dbl> <dbl>
#> 1 316 0.102
#> 2 323 0.168
#> 3 328 0.265
#> 4 331 0.290
#> 5 337 0.261
#> 6 341 0.305
#> 7 344 0.268
#> 8 349 0.298
#> 9 352 0.323
#> 10 358 0.254
#> # ℹ 65 more rows