Last chance! 50% off unlimited learning
Sale ends in
Takes a sample of the specified size from the elements of a
"timeSeries"
.
# S4 method for timeSeries
sample(x, size, replace = FALSE, prob = NULL)
an object from class "timeSeries"
an object from class "timeSeries"
.
a non-negative integer giving the number of items to choose.
sample with replacement if TRUE
, otherwise without
replacement.
a vector of probability weights for obtaining the elements of the vector being sampled.
The function takes a sample of size size
from the elements of
the time series with or without replacement depending on argument
replace
. The result is returned as a "timeSeries"
object.
For details about the arguments see the documentation of
base:sample
.
## Monthly Calendar Series -
x <- daily2monthly(LPP2005REC[, 1:2])[3:14, ]
set.seed(1234)
## Resample the Series with respect to the time stamps -
resampled <- sample(x)
resampled
is.unsorted(resampled)
Run the code above in your browser using DataLab