Write Tableau friendly dataframe
write_tableau.Rd
This function takes a dataframe, renames its columns based on a mapping file, applies some transformations, and saves the result in a specified location.
Usage
write_tableau(
df,
name,
output_path,
current_year,
student_number_col = "INS_Studentnummer",
enrolment_year_col = "INS_Inschrijvingsjaar",
mapping_file = "Documentatie_Tableau_vriendelijke_variabelnamen_UT.csv",
save_csv = TRUE,
save_rds = FALSE,
offset_years = 10
)
Arguments
- df
A dataframe.
- name
A character string specifying the name of the output files.
- output_path
A character string specifying the directory where the output files should be saved.
- current_year
An integer specifying the current year.
- student_number_col
Character string specifying the column name for student numbers. Default is "INS_Studentnummer".
- enrolment_year_col
Character string specifying the column name for enrolment years. Default is "INS_Inschrijvingsjaar".
- mapping_file
Character string specifying the name of the mapping file. Default is "Documentatie_Tableau_vriendelijke_variabelnamen_UT.csv".
- save_csv
Logical indicating whether to save the output as a CSV file. Default is TRUE.
- save_rds
Logical indicating whether to save the output as an RDS file. Default is FALSE.
- offset_years
An integer specifying the range of years to consider when filtering the 'INS_Inschrijvingsjaar' column. Default is 10.