This function subsets a dataframe to return only subjects who have more than one unique visit. It takes in the column names for the subject identifier and the visit identifier, then filters the dataframe to include only rows corresponding to subjects with multiple distinct visits.

subset_multiple_visits(data, subject_identifier, visit_identifier)

Arguments

data

A dataframe containing the data to be subset.

subject_identifier

A string specifying the column name used to identify subjects.

visit_identifier

A string specifying the column name used to identify visits.

Value

A dataframe containing only subjects with more than one unique visit.

Examples

# Example dataframe
df <- data.frame(
  subjectID = c(1, 1, 2, 2, 3, 3, 4),
  visitID = c(1, 2, 1, 1, 1, 3, 1)
)

# Subset for subjects with multiple unique visits
result <- subset_multiple_visits(df, "subjectID", "visitID")
print(result)
#> # A tibble: 4 × 2
#>   subjectID visitID
#>       <dbl>   <dbl>
#> 1         1       1
#> 2         1       2
#> 3         3       1
#> 4         3       3