combine_ts | R Documentation |
Combines one or more ts and/or const data.frames, joining on DateTime. The data.frames are iteratively added to the first one, moving left to right in the list of inputs. The first element must be a time series. If a subsequent element is a constant (1 row, with DateTime=NA) then that constant is added for all rows.
combine_ts(..., method = c("full_join", "left_join", "inner_join", "approx"),
approx_tol = as.difftime(3, units = "hours"))
... |
one or more ts and/or const data.frames to be combined |
method |
character specifying the method to use to combine the data.frames |
approx_tol |
difftime. ignored if method != 'approx'. if method == 'approx', the maximum time interval over which an approximation will be used to fill in data gaps in the 2nd:nth data argument to combine_ts (relative to the first argument) |
## Not run:
xy <- download_ts(c('suntime_calcLon', 'wtr_nwis'), 'nwis_01467087', on_local_exists="replace")
suntime <- read_ts(xy[1])[410:520,]
wtr <- read_ts(xy[2])[400:545,]
fulljoined <- combine_ts(suntime, wtr, method='full_join')
approxjoined <- combine_ts(suntime, wtr, method='approx')
library(ggplot2)
ggplot(unitted::v(approxjoined), aes(x=DateTime, y=wtr)) +
geom_line(color="blue") + theme_bw() +
geom_line(data=unitted::v(fulljoined), color="red")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.