| pull_sample | R Documentation |
A method to extract a random sample of members from a list, a collection of spectra or a spectrum object containing multiple spectra in long form.
pull_sample(x, size, ...)
## Default S3 method:
pull_sample(x, size, ...)
## S3 method for class 'list'
pull_sample(
x,
size = 1,
replace = FALSE,
keep.order = TRUE,
method = "random",
simplify = FALSE,
...
)
## S3 method for class 'generic_spct'
pull_sample(
x,
size = 1,
replace = FALSE,
keep.order = TRUE,
method = "random",
...
)
## S3 method for class 'generic_mspct'
pull_sample(
x,
size = 1,
replace = FALSE,
keep.order = TRUE,
method = "random",
recursive = FALSE,
simplify = FALSE,
...
)
x |
An R object possibly containing multiple spectra or other components. |
size |
integer The number of spectra to extract, if available. |
... |
currently ignored. |
replace |
logical Sample with or without replacement. |
keep.order |
logical Return the spectra ordered as in |
method |
character Use |
simplify |
logical If |
recursive |
logical If |
This function calls sample() to generate a random set of
indexes, or a regular sequence, and uses it to extract members from lists or
collections. Method "equal.steps" is most useful for time series
of spectra. With recursive = TRUE lists and list-like collections
are first flattened, and with recursive = FALSE sampling is applied
to the topmost level only.
If x is an spectrum object, such as a
"filter_spct" object, the returned object is of the same class but
in most cases containing fewer spectra in long form than x.
If x is a collection of spectrum objecta, such as a
"filter_mspct" object, the returned object is of the same class but
in most cases containing fewer member spectra than x.
See sample for the method used for
the sampling.
a.list <- as.list(letters)
names(a.list) <- LETTERS
set.seed(12345678)
pull_sample(a.list, size = 8)
pull_sample(a.list, size = 7, method = "equal.steps")
pull_sample(a.list, size = 8, keep.order = FALSE)
pull_sample(a.list, size = 8, replace = TRUE)
pull_sample(a.list, size = 8, replace = TRUE, keep.order = FALSE)
pull_sample(a.list, size = 1)
pull_sample(a.list, size = 1, simplify = TRUE)
set.seed(12345678)
pull_sample(sun_evening.spct, 2)
set.seed(12345678)
pull_sample(sun_evening.mspct, 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.