output_to_excel: Tables to excel

Description Usage Arguments Examples

Description

Write out data in table format easily to excel

Usage

1
2
3
4
5
output_to_excel(x, wb = NULL, sheet = NULL, start_row = 1,
  start_col = 1, header_style = NULL, header_color = "#d3daea",
  fmt_side = TRUE, open_wb = TRUE, pct_keys = "percent|pct|%|rate",
  auto_col_width = TRUE, cond_fmt_cols = NULL, keep_na = FALSE,
  rows_btwn = 2, verbose = TRUE)

Arguments

x

an list of or single object of class data.frame, data.table , matrix or report.table to write out to excel.

wb

a workbook object created with createWorkbook using code such as openxlsx::createWorkbook(). If no workbook object is set one will be created in the function.

sheet

the name of a sheet created in the workbook object created using function addWorksheet using code such as openxlsx::addWorksheet(wb = wb, sheetName = <name of x>), where the name of the sheet will be the name of the object passed into x

start_row

the row to start writing the table or list of tables to.

start_col

the column to start writing the table or list of tables to.

header_style

a style created using openxlsx::createStyle to apply to the header of the table

header_color

a color to use for the header background color. Ignored if header_style is set.

fmt_side

if header_side should also be applied to the first columns of the table of list of tables be output. Default is set to TRUE.

open_wb

if the workbook object should be opened after the table has been written.

pct_keys

a regex argument to use to search for columns that should be automatically formatted as percents when the table is output to excel. Setting this function to NULL will result in no columns being formatted as percents. Default is set to "percent|pct|%|rate".

auto_col_width

automattically set column widths of the tables being output.

cond_fmt_cols

columns of the tables to apply conditional formatting to.

keep_na

if set to FALSE cells that contain NA will be left blank in the excel document. Otherwise "NA" will be written out as a string in excel. Default is FALSE.

rows_btwn

if x is a list of tables the number if rows to place between tables.

verbose

if TRUE print the progress of the table output. Default is set to TRUE.

Examples

1
2
3
4
5
6
7
8
9
# Create a bivariate of vs by cyl
tab1 <- bivar_table(x = mtcars, var = "cyl", bivar = "vs")
tab2 <- bivar_table(x = mtcars, var = "gear", bivar = "vs")

# output a single table
output_to_excel(tab1)

# output a list of tables
output_to_excel(list(tab1, tab2, tab1, tab2))

jinlow/report.tools documentation built on June 2, 2019, 10:55 p.m.