Description Usage Arguments Value Methods (by class) Examples
Sample observation values from a time series at given sampling times.
1 2 3 4 5 6 7 8 9 10 11 | sample_values(x, ...)
## S3 method for class 'uts'
sample_values(
x,
time_points,
interpolation = "last",
max_dt = Inf,
tolerance = .Machine$double.eps^0.5,
...
)
|
x |
a time series object. |
... |
further arguments passed to or from methods. |
time_points |
a strictly increasing sequence of |
interpolation |
the interpolation method:
|
max_dt |
a duration object, specifying the maximum time difference between each sampling time and the observation times in |
tolerance |
tolerance for numerical noise in observation times. See |
An vector of sampled values with same length as the input x
.
uts
: sample from a "uts"
object
1 2 3 4 5 6 7 8 9 10 11 12 | # Sample the most recent observation
times <- as.POSIXct(c("2007-11-09", "2007-11-10"))
sample_values(ex_uts(), times)
# Sample with linear interpolation
sample_values(ex_uts(), times, interpolation="linear")
# Sample a non-numeric time series
sample_values(ex_uts2(), times)
# Error, because only numeric time series can be linearly interpolated
## Not run: sample_values(ex_uts2(), as.POSIXct("2007-01-01"), interpolation="linear")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.