| pair_ts | R Documentation |
This function adds observations from one timeseries to another timeseries using a matching process (e.g., nearest neighbour interpolation). This is useful when you have a main dataframe to which you need to add observations (e.g., those occurring closest in time) from another dataframe.
pair_ts(
d1,
d2,
time_col,
key_col = NULL,
val_col,
method = "match_ts_nearest",
min_gap = NULL,
max_gap = min_gap,
units = "mins",
control_beyond_gap = NULL
)
d1 |
A dataframe that contains, at a minimum, a vector of timestamps, to which observations are added from |
d2 |
A dataframe that contains, at a minimum, a vector of timestamps and associated observations, to be added to |
time_col |
A character that defines the name of the column that contains timestamps in |
key_col |
(optional) A character that defines the name of the column that contains keys in |
val_col |
A character that defines the name of the column that contains observations in |
method |
A character that defines the matching method. The options currently implemented are |
min_gap |
(optional) A number that defines the minimum time gap (in user-defined units, see |
max_gap |
As above, for |
units |
A character that defines the units of the inputted |
control_beyond_gap |
A character that defines whether or not to rows from |
The function returns a dataframe, d1, as inputted, with an added column (whose name is given by val_col), comprising values added from another dataframe, d2. Any observations in d1 for which there are not observations in d2 occurring within some time window (defined by min_gap and max_gap), if specified, are counted and, if requested, removed from the returned dataframe.
Edward Lavender
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.