Function to export data from R to a formatted .xlsx-file. The data is exported to the first sheet. Metadata information is exported to the second sheet.

aXLSX(
  file,
  data,
  title = NULL,
  source = NULL,
  metadata = NULL,
  grouplines = NULL,
  group_names = NULL,
  logo = NA,
  contactdetails = NA,
  homepage = NA,
  author = "user",
  config = "default"
)

Arguments

file

file name of the xlsx-file. The extension ".xlsx" is added

data

data to be included.

title

title to be put above the data.

source

source of the data. Default can be adjusted via user profiles

metadata

metadata information to be included. Defaults to NA, meaning no metadata are attached.

grouplines

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.

group_names

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.

logo

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.

contactdetails

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

Homepage of data publisher. Default can be adjusted via user configuration.

author

defaults to the last two letters (initials) or numbers of the internal user name.

config

which config file should be used. Default: default

Note

This function is well-suited for applications where a single dataset needs to be accompanied by a second sheet with explanations or other complex metadata.

Examples

if (FALSE) {
aXLSX(file = tempfile(fileext = ".xlsx"),
      data = mtcars,
      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)."))
}