R/subtyper.R
subset_multiple_visits.Rd
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)
A dataframe containing only subjects with more than one unique visit.
# 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