df_to_xlsx: Add Dataframe to Excel File

View source: R/df_to_xlsx.R

df_to_xlsxR Documentation

Add Dataframe to Excel File

Description

This function adds a data.frame to an excel file, formatting the header. Also allows to select columns where rows with equal values are merged.

Usage

df_to_xlsx(
  excel_file,
  sheet_name,
  df,
  auto_size_cols = TRUE,
  merge_cols = NULL,
  nested_merge = TRUE
)

Arguments

excel_file

Location of excel file where data.frame will be added

sheet_name

Name of the sheet inside the file -will replace sheets with same name-

df

Data.frame to be added to file

auto_size_cols

Should column width be changed based on their contents? TRUE or FALSE, defaults to TRUE

merge_cols

Names of columns that should be merged vertically when they have the same value. Default is no merging, expects a character vector

nested_merge

Should merging be done with columns on the right being nested inside the ones on the left? TRUE or FALSE

Value

Excel file with data.frame added

Examples

df_to_xlsx(excel_file = "./excel.xlsx", sheet_name = "information", df = info_df, merge_cols = c("Continent", "Country"))

MarcioFCMartins/MMartins documentation built on Jan. 26, 2024, 3:10 p.m.