Learn R Programming

OpenRepGrid (version 0.1.18)

saveAsWorksheet: Add grids as sheets to an openxlsx Workbook

Description

saveAsWorksheet will add one or more grids to an a openxlsx Workbook object.

Usage

saveAsWorksheet(x, wb, format = "wide", sheet = NULL, default_sheet = "grid")

Value

Invisibly returns Workbook object.

Arguments

x

A repgrid object or a list of grids.

wb

A openxlsx Workbook object.

format

Two output formats are supported: wide (default) where each column represents one element, each row represent one constructs (a common grid representation), and long where each row contains an element-construct combination and the corresponding rating value. See importExcel() for details and examples.

sheet

Vector of sheet names with same length as x. If NULL (default), default_sheet is used. If x is a list if grids, a sequential index is appended. For named list entries (if x is a list of grids), the name overwrites the default sheet name.

default_sheet

Default sheet name to use if not supplied in sheet or via list names of x.

See Also

saveAsExcel()

Examples

Run this code
library(openxlsx)

wb <- createWorkbook()

# add grid to worksheet
saveAsWorksheet(boeker, wb, sheet = "boeker")

# add several grids with explicit sheet names
l <- list(bell2010, feixas2004)
saveAsWorksheet(l, wb, sheet = c("Bell 2010", "Feixas 2004"))

# list names are used as sheet names. Without name, the default applies.
l <- list(boeker, "Fransella et al. 2003" = fbb2003)
saveAsWorksheet(l, wb)


# save as Excel file
file <- tempfile(fileext = ".xlsx")
saveWorkbook(wb, file)
if (FALSE) {
  browseURL(file) # may not work on all systems
}

Run the code above in your browser using DataLab