write_list_to_excel: Write a List of Data Frames to an Excel File

View source: R/write_list_to_excel.R

write_list_to_excelR Documentation

Write a List of Data Frames to an Excel File

Description

This function writes a list of data frames to an Excel file, with each element of the list being written to a separate sheet. It preprocesses the data frames to replace NA values with a placeholder string, writes the data to the workbook, and then clears the cells containing the placeholder string to ensure they are treated as truly empty cells in Excel.

Usage

write_list_to_excel(data_list, file_name, placeholder = "NA_PLACEHOLDER")

Arguments

data_list

A named list of data frames to be written to the Excel file. Each list element will be written to a separate sheet.

file_name

A character string specifying the name of the output Excel file.

placeholder

A character string used as a placeholder to replace NA values in the data frames. Default is "NA_PLACEHOLDER".

Value

This function does not return a value. It writes the list of data frames to an Excel file.

Examples

## Not run: 
Example workflow:

# Create an empty list to store results from some analyses
results <- list()

# results from each analysis step are added to the list
analysis1_result <- data.frame(A = 1:5, B = letters[1:5])
results$analysis1_result <- as.data.frame(analysis1_result)

analysis2_result <- data.frame(X = rnorm(5), Y = runif(5))
results$analysis2_result <- as.data.frame(analysis2_result)

# Write the list to an Excel file with each element on a separate sheet
write_list_to_excel(results, "example.xlsx")

## End(Not run)

pygmyperch/melfuR documentation built on Aug. 26, 2024, 12:48 a.m.