Learn R Programming

bivarhr (version 0.1.5)

add_sheet: Add a worksheet to an Excel workbook with flexible content

Description

Convenience helper that adds a worksheet to a global workbook object and writes either a single data frame, or a nested list of objects (data frames or other structures) in a readable layout.

Usage

add_sheet(name, df)

Value

Invisibly returns NULL. The workbook wb is modified in place.

Arguments

name

Character scalar; name of the worksheet to add.

df

Either a data frame to write directly, or a list whose elements can be data frames, lists of data frames, or arbitrary R objects. Non-data-frame objects are written using the output of str().

Details

This function assumes that a global wb object exists (an openxlsx workbook). When df is a list, it iterates over list elements and writes labeled sections for each element and its sub-elements.

If df is NULL, a one-row data frame with the message "Sin datos" is written.