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)

Arguments

reference_df

A data frame containing the reference dataset.

target_df

A data frame containing the target dataset to search within.

k

The number of closest subjects to find.

sex_col_name

The name of the column in the datasets that contains subjects' sex.

age_col_name

The name of the column in the datasets that contains subjects' age.

Value

A data frame with the rows from target_df that are closest to reference_df based on the criteria.

Examples

# find_closest_subjects(referenceData, targetData, 5, "Gender", "Age")