match.merge | R Documentation |
the rows from y
are matched with rows from x
that
share the same ID and directly precede them in date.
match.merge(x, y, idvar, datevar, keep.unmatched = c("all", "x", "y", "none"))
x , y |
The |
idvar |
Name of the variable holding participant/session IDs in both x and y. |
datevar |
Name of the variable holding dates in both x and y. |
keep.unmatched |
When no match is found for a row, should it be kept or removed? |
This is useful for matching participant data from different datasets,
where one dataset is always collected after another. It is assumed here that
x
is always administered before y
.
This matches using [match.pps()] and merges using [dplyr::full_join()].
A merged data.frame
where rows of x
are merged with rows of y
that match by session id and where
the date of each row from x
directly precedes the
date of the matched row from y
.
Sercan Kahveci
x <- data.frame(id=c(1,2,2,3,3,4),
date=as.POSIXct(c(1,1,3,1,3,1)),
info=letters[1:6])
y <- data.frame(id=c(1,2,3,3,4),
date=as.POSIXct(c(2,2,4,2,0)),
data=LETTERS[1:5])
match.merge(x=x,y=y,idvar="id",datevar="date",keep.unmatched="all")
match.merge(x=x,y=y,idvar="id",datevar="date",keep.unmatched="none")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.