importExcel {OpenRepGrid}R Documentation

Import grid data from an Excel file.

Description

You can define a grid in a Microsoft Excel file (suffix .xlsx). The file must have one of two formats (wide or long, see format sections below).

Usage

importExcel(file, sheet = 1, format = "wide", rmin = NULL, rmax = NULL)

Arguments

file

Path(s) to Excel file(s) (suffix .xlsx).

sheet

Names or indexes of sheet with grid data to import.

format

Two formats are supported. wide (default): each column represents one element, each row represent one constructs. long: each row contains one rating value for a element-construct combination. See sections below and examples.

rmin, rmax

Min and max of the rating scale (numeric, default NULL).

Value

A repgrid object (one input file) or a named list with repgrid objects (several input files). List names are filename + sheet.

Format wide

In the wide format, each element has a separate column, and each row contains the ratzings for one construct. It is a common way to represent grid data and looks like this:

1 element_1 element_2 element_3 element_4 5 preferred
left_pole_1 1 5 3 4 right_pole_1 left
left_pole_2 3 1 1 3 right_pole_2 right
left_pole_3 4 2 5 1 right_pole_3 NA

The header row contains the minimum of the rating scale (1), the names of the elements (element_1 to element_4), the maximum of the rating scale (5), and optionally the column preferred, indicating the preferred pole. Each row contains the constructs entries (left pole, ratings, right pole, preferred pole). The preferred pole must be one of left, right, none, NA (see preferredPoles()).

Format long

The long format has this name because it has few columns and many rows. It is a common format in data analytics. Here, each row contains a different element-construct combination and the corresponding rating value. The format looks like this:

element left_pole right_pole rating preferred_pole rmin rmax
⁠element 1⁠ ⁠left pole 1⁠ ⁠right pole 1⁠ 1 left 1 5
element_2 ⁠left pole 1⁠ ⁠right pole 1⁠ 5 left 1 5
element_3 ⁠left pole 1⁠ ⁠right pole 1⁠ 4 left 1 5

The columns element, left_pole, right_pole, and rating are mandatory, the columns preferred_pole, rmin, and rmax are optional. rmin and rmax contain the min and max of the rating scale. Alternatively, you may pass rmin and rmax as arguments in the function call.

See Also

Import data importDataframe(), importGridcor(), importGridstat(), importGridsuite(), importScivesco(), importTxt()

Examples

file <- system.file("extdata", "grid_01.xlsx", package = "OpenRepGrid")
rg_1 <- importExcel(file, sheet = "wide")
rg_2 <- importExcel(file, sheet = "long", format = "long")

# Open sample file to inspect it (requires Excel to be installed).
## Not run: 
browseURL(file) # may not work on all systems 
## End(Not run)

# Import more than one Excel file
files <- system.file("extdata", c("grid_01.xlsx", "grid_02.xlsx"), package = "OpenRepGrid")
rgs <- importExcel(files) # returns a list of grids

# Impoort from several sheets at once (all must have same format)
file <- system.file("extdata", "grid_03.xlsx", package = "OpenRepGrid")
rgs <- importExcel(file, sheet = 1:3) # by index
rgs <- importExcel(file, sheet = c("grid 1", "grid 2", "grid 3")) # or by name

[Package OpenRepGrid version 0.1.18 Index]