Function to export data from R as a formatted .xlsx-file, distributed over multiple worksheets based on a grouping variable (e.g., year).
splitXLSX(
file,
data,
sheetvar,
title = NULL,
source = NULL,
metadata = NULL,
grouplines = NULL,
group_names = NULL,
logo = NA,
contactdetails = NA,
homepage = NA,
author = "user",
config = "default"
)
file name of the xlsx-file. The extension ".xlsx" is added
data to be included.
name of the variable used to split the data and spread them over several sheets.
title to be put above the data.
source of the data. Default can be adjusted via user profiles
metadata information to be included. Defaults to NA, meaning no metadata are attached.
Can be used to visually group variables. Values should either correspond to numeric column indices or column names, denoting the first variable in a group. Defaults to NA, meaning no lines are added.
A vector of names for groups to be displayed in a secondary header. Should be of the same length as grouplines, and cannot be used unless these are set. Defaults to NA, meaning no secondary header is created.
File path to the logo to be included in the index-sheet. Defaults to the logo of the Statistical Office of Kanton Zurich. This can either be overridden with a path to an image file, or configured in a user profile.
Character vector with contact information to be displayed
on the title sheet. By default uses inputHelperContactInfo()
to
construct it based on values defined in the active user configuration.
Homepage of data publisher. Default can be adjusted via user configuration.
defaults to the last two letters (initials) or numbers of the internal user name.
which config file should be used. Default: default
User should make sure that the grouping variable is of binary, categorical or other types with a limited number of levels.
if (FALSE) {
splitXLSX(file = tempfile(fileext = ".xlsx"),
data = mtcars,
sheetvar = "cyl",
title = "Motor trend car road tests",
source = paste("Source: Henderson and Velleman (1981),",
"Building multiple regression models interactively.",
"Biometrics, 37, 391–411."),
metadata = paste("The data was extracted from the 1974 Motor Trend",
"US magazine and comprises fuel consumption and",
"10 aspects of automobile design and performance",
"for 32 automobiles (1973–74 models)."))
}