This function identifies the closest subjects in a target dataset to a reference dataset based on specified criteria such as sex and age.
find_closest_subjects(reference_df, target_df, k, sex_col_name, age_col_name)
A data frame containing the reference dataset.
A data frame containing the target dataset to search within.
The number of closest subjects to find.
The name of the column in the datasets that contains subjects' sex.
The name of the column in the datasets that contains subjects' age.
A data frame with the rows from target_df
that are closest to reference_df
based on the criteria.
# find_closest_subjects(referenceData, targetData, 5, "Gender", "Age")