Learn R Programming

tabxplor (version 1.1.0)

tab_xl: Excel output for tabxplor tables, with formatting and colors

Description

To modify the colors used into the Excel table, you can change the global options with set_color_style and set_color_breaks.

Usage

tab_xl(
  tabs,
  path = NULL,
  replace = FALSE,
  open = rlang::is_interactive(),
  colnames_rotation = 0,
  remove_tab_vars = TRUE,
  colwidth = "auto",
  print_ci = FALSE,
  print_color_legend = TRUE,
  sheets = "tabs",
  min_counts = 30,
  hide_near_zero = "auto",
  color_type = "text"
)

Arguments

tabs

A table made with tab, tab_many or tab_plain, or a list of such tables.

path, replace, open

The name, and possibly the path, of the Excel file to create (possibly without the .xlsx extension). Default path to temporary directory. Set global option "tabxplor.export_dir" with link[base:options]{options} to change default directory. Use replace = TRUE to overwrite existing files. Use open = TRUE if you don't want to automatically open the tables in Excel (or another software associated with .xlsx files).

colnames_rotation

Rotate the names of columns to an angle (in degrees).

remove_tab_vars

By default, tab_vars columns are removed to gain space. Set to FALSE to keep them.

colwidth

The standard width for numeric columns, as a number. Default to "auto".

print_ci

By default provided confidence intervals are printed in another table, left to the base table. Set to FALSE to dismiss.

print_color_legend

Should the color legends be printed with the subtexts ?

sheets

The Excel sheets options :

  • "tabs": a new sheet is created for each table

  • "unique": all tables are on the same sheet

  • "auto": subsequent tables with the same columns are printed on the same sheets

min_counts

The total count under which a column or row is turned pale grey because there is not enough observation for it to be significant. Default to 30.

hide_near_zero

By default all cells displayed as 0 (even rounded) turn pale grey, to make the distribution of empty cells (and other cells) more visible. Provide a number to turn grey every cell below it. Set to Inf not to use this feature.

color_type

By default, the background is colored. Set to text to color the text instead.

Value

The table(s) with formatting and colors in an Excel file, as a side effect. Invisibly returns tabs.

Examples

Run this code
# NOT RUN {
forcats::gss_cat %>%
  tab(marital, race, pct = "row", color = "diff") %>%
  tab_xl()
  
# }

Run the code above in your browser using DataLab