Learn R Programming

OpenRepGrid (version 0.1.18)

saveAsExcel: Save grids as Microsoft Excel file (.xlsx)

Description

saveAsExcel will save one or more grids in an Excel file (.xlsx).

Usage

saveAsExcel(x, file, format = "wide", sheet = NULL, default_sheet = "grid")

Value

Invisibly returns file path.

Arguments

x

A repgrid object or a list of grids.

file

File path. Suffix must be .xlsx.

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

importExcel(), saveAsWorksheet()

Examples

Run this code
# save one grid in wide format (default)
file <- tempfile(fileext = ".xlsx")
saveAsExcel(boeker, file)
if (FALSE) {
browseURL(file) # open file, requires Excel, may not work on all system
}

# save one grid in log format
file <- tempfile(fileext = ".xlsx")
saveAsExcel(boeker, file, format = "long")
if (FALSE) {
browseURL(file)
}

# save a list of grids
file <- tempfile(fileext = ".xlsx")
l <- list(boeker, feixas2004, bell2010)
saveAsExcel(l, file)
if (FALSE) {
  browseURL(file)
}

# pass some sheet names (2nd with named sheet)
file <- tempfile(fileext = ".xlsx")
l <- list(boeker, "feixas' grid" = feixas2004)
saveAsExcel(l, file)
if (FALSE) {
  browseURL(file)
}

Run the code above in your browser using DataLab