base-sample: Resample 'timeSeries' objects

sampleR Documentation

Resample 'timeSeries' objects

Description

Takes a sample of the specified size from the elements of a "timeSeries".

Usage

## S4 method for signature 'timeSeries'
sample(x, size, replace = FALSE, prob = NULL)

Arguments

x

an object from class "timeSeries".

size

a non-negative integer giving the number of items to choose.

replace

sample with replacement if TRUE, otherwise without replacement.

prob

a vector of probability weights for obtaining the elements of the vector being sampled.

Details

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.

Value

an object from class "timeSeries"

See Also

sample (sample in base R),

sample (the "timeDate" method)

Examples

   
## Monthly Calendar Series -    
   x <- daily2monthly(LPP2005REC[, 1:2])[3:14, ]
   

## Resample the Series with respect to the time stamps -    
   resampled <- sample(x)
   resampled
   is.unsorted(resampled)

timeSeries documentation built on Jan. 13, 2024, 8:16 p.m.