match.pps: Match recurring session IDs using their date

View source: R/datawrangler.R

match.ppsR Documentation

Match recurring session IDs using their date

Description

Match session IDs from two datasets by taking into account the date of the sessions. This is useful when linking together data from several experiments done by the same participants; often participants accidentally run the same experiment twice, so this should help to distinguish which experiment datasets temporally fit together.

Usage

match.pps(x.ids, x.dates, y.ids, y.dates)

Arguments

x.ids, y.ids

IDs to match.

x.dates, y.dates

Dates to use in the matching of IDs.

Value

A data.frame with two columns, one specifying the indices of x and one specifying the matched indices of y.

Author(s)

Sercan Kahveci

Examples

# In the following example, participant 1 has a single direct match,
# one of participant 2's two sessions in x can be matched to a session in y,
# both of participant 3's sessions in x have a match in y,
# and participant 4 has no match between x and y because the observation in y
# occurs before that in x
x <- data.frame(id=c(1,2,2,3,3,4),
                date=as.POSIXct(c(1,1,3,1,3,1)))
y <- data.frame(id=c(1,2,3,3,4),
                date=as.POSIXct(c(2,2,4,2,0)))
match.pps(x.ids=x$id,x.dates=x$date,y.ids=y$id,y.dates=y$date)
#>   x.rowid y.rowid
#> 1       1       1
#> 2       2       2
#> 3       5       3
#> 4       4       4


Spiritspeak/skMisc documentation built on April 12, 2025, 5:40 a.m.