Writes data to an Excel file.
Arguments
- data
A data frame or a list of data frames. If a data frame, it will be written to a single sheet in the Excel workbook. If a list, each data frame will be written to a separate sheet in the Excel workbook. Data may also be the output to model_mf, in which case set
model_results = TRUE
.- output_path
The directory where the Excel file should be written. Default is NULL, which will write the file to the current working directory.
- workbook_name
The file name for the Excel file.
- model_results
A logical value indicating whether the data is the output of model_mf. Default is FALSE. If TRUE, the function will grab the model_data, point_estimates, and pairwise_comparisons data frames from the model_mf output and write them to separate sheets in the Excel workbook.
Examples
if (FALSE) { # \dontrun{
example_file <- system.file("extdata", "Example_files",
"example_mutation_data_filtered.rds",
package = "MutSeqR")
example_data <- readRDS(example_file)
mf1 <- calculate_mf(example_data,
cols_to_group = "sample",
subtype_resolution = "none",
retain_metadata_cols = "dose")
mf2 <- calculate_mf(example_data,
cols_to_group = c("sample", "label"),
subtype_resolution = "none")
mf3 <- calculate_mf(example_data,
cols_to_group = "dose",
subtype_resolution = "base_6",
variant_types = c("-ambiguous", "-uncategorized"))
list <- list(mf1, mf2, mf3)
names(list) <- c("mf1", "mf2", "mf3")
# save a single data frame to an Excel file
write_excel(mf1, output_path, workbook_name = "test_single")
#save a list of data frames to an Excel file
write_excel(list, output_path, workbook_name = "test_list")
# save model results to an Excel file
model <- model_mf(mf1,
fixed_effects = "dose",
reference_level = 0,
contrasts = data.frame(col1 = c(12.5, 25, 50),
col2 = rep(0,3)))
write_excel(model,
workbook_name = "test_model",
model_results = TRUE)
} # }