Description Usage Arguments Examples
The accessor method ("["
) extracts a sub-sampled time series with the provided times. The replacement method ("[<-"
) inserts observation values at the provided observation times, replacing observations values for already existing observation times (if any).
1 2 3 4 5 |
x |
a |
time_points |
either a strictly increasing sequence of |
... |
further arguments passed to |
value |
a vector of observation values to insert at the time points |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Sample at single time point
ex_uts()[as.POSIXct("2000-01-01")]
# Sample at multiple time points, optionally restricting the maximum time difference
# between sampling and observation times
times <- as.POSIXct(c("2007-11-08 11:01:00", "2007-11-09 15:16:00"))
ex_uts()[times]
ex_uts()[times, max_dt = dhours(1)]
# Insert multiple numeric values
test <- ex_uts()
test[Sys.time() + ddays(1:2)] <- c(51, 52)
# Insert non-numeric value
test <- ex_uts()
test[Sys.time() + ddays(3)] <- list(cat=1, dog=2)
# Replacement times from logical "uts"
test <- ex_uts()
test[test >= 48] <- 50
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.