match_ts_nearest_by_key | R Documentation |
For two dataframes, d1
and d2
, this function finds the positions in the second dataframe which, for each key (e.g., factor level, individual) in the first dataframe, are nearest in time (i.e., nearest neighbour interpolation accounting for observations from different factor levels).
match_ts_nearest_by_key(d1, d2, key_col, time_col)
d1 |
A dataframe which includes a column that defines factor levels and a column that defines timestamps. The names of these columns need to match those in |
d2 |
A dataframe which includes a column that defines factor levels and a column that defines timestamps. The names of these columns need to match those in |
key_col |
A character that defines the column name in |
time_col |
A character that defines the column name in |
If there are multiple matches, only the first is returned.
For a dataframe comprising observations from a series of factor levels (e.g., individuals) collected through time, the function returns a vector of positions in a second dataframe which, for the appropriate factor level, are nearest in time.
Edward Lavender
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.