Learn R Programming

vald.extractor (version 0.1.1)

patch_metadata: Fix Missing or Incorrect Athlete Demographics

Description

Allows users to provide an external Excel or CSV file containing corrected demographic information (e.g., sex, date of birth) for athletes with missing or incorrect data in the VALD system. This function merges the corrections and updates the master metadata.

Usage

patch_metadata(
  data,
  patch_file,
  patch_sheet = 1,
  id_col = "profileId",
  fields_to_patch = c("sex", "dateOfBirth"),
  verbose = TRUE
)

Value

Data frame with patched metadata.

Arguments

data

Data frame. Master metadata or analysis dataset.

patch_file

Character. Path to Excel (.xlsx) or CSV (.csv) file containing corrections.

patch_sheet

Character or integer. For Excel files, which sheet to read. Default is 1 (first sheet).

id_col

Character. Name of the ID column in both data and patch_file. Default is "profileId".

fields_to_patch

Character vector. Column names to update from the patch file. Default is c("sex", "dateOfBirth").

verbose

Logical. If TRUE, prints progress messages. Default is TRUE.

Details

Patch Missing Metadata from External File

Examples

Run this code
# \donttest{
if (FALSE) {
  # Create an Excel file with columns: profileId, sex, dateOfBirth
  # Then patch the metadata
  patched_data <- patch_metadata(
    data = athlete_metadata,
    patch_file = "corrections.xlsx",
    fields_to_patch = c("sex", "dateOfBirth")
  )

  # Check results
  table(patched_data$sex)
}
# }

Run the code above in your browser using DataLab