mergeNearest | R Documentation |
Merge two datasets based on the the nearest date between each observation.
mergeNearest(left, dates.left = "DATES", all.left = FALSE, suffix.left = "left", right, dates.right = "DATES", suffix.right = "right", Date.noon = TRUE, max.diff = "7 days")
left |
the left-hand dataset. |
dates.left |
the name of the column of dates in the left-hand dataset. |
all.left |
logical ( |
suffix.left |
the suffix to apply to common column names in the left-hand dataset. |
right |
the right-hand dataset. |
dates.right |
the name of the column of dates in the right-hand dataset. |
suffix.right |
the suffix to apply to common column names in the right-hand dataset. |
Date.noon |
logical ( |
max.diff |
the maximum allowable difference in time for a match. See Details. |
The format for max.diff
should be a numeric value followed by a
description of the time span. The time span must be one of "secs," "mins,"
"hours," "days," or "weeks" for seconds, minutes, hours, days, or weeks,
respectively.
A data frame of the merged data with common column names renamed by
the suffix
arguments to avoid conflict.
Water-quality data taken at a specific time frequently need to be merged with daily flow data or merged with other water-quality data such as replicate samples or samples of a different medium taken at about the same time, but having a different time stamp.
mergeQ
library(smwrData) data(Q05078470) data(QW05078470) # Set the actual time of sampling in QW05078470 QW05078470 <- transform(QW05078470, DATES=DATES + as.timeDay(TIMES)) mergeNearest(QW05078470, right=Q05078470) # Notice the difference in selected dates mergeNearest(QW05078470, right=Q05078470, Date.noon=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.