8  Export To Excel

Code
out_type <- knitr::opts_chunk$get("rmarkdown.pandoc.to")

1 Read all tabular data

We read all tabular data from the previous section.

2 Export Data as Excel

We export the standardised data to an excel file called harmonised_Cohort_B.xlsx

Code
# Create a new workbook
my_workbook <- openxlsx::createWorkbook()

sheet_name = c("demographics")

output_data = list(demo_behave_data)  |> 
  purrr::map(
    .f = harmonisation::add_cohort_name,
    cohort_name = params$cohort_name,
    cohort_name_column = "cohort_name"
  )

purrr::walk2(
    .x = sheet_name,
    .y = output_data,
    .f = harmonisation::write_to_sheet,
    workbook = my_workbook
)

# Save workbook
openxlsx::saveWorkbook(
  wb = my_workbook, 
  file = here::here(params$analysis_folder,
                    params$output_folder,
                    params$cleaned_folder,
                    params$output_excel_file),
  overwrite = TRUE
)