importDataframe {OpenRepGrid}R Documentation

Convert a dataframe into a repgrid object.

Description

There are three different dataframe formats from which a repgrid object can be created: Columns are a) element_columns, b) construct_columns, c) long. Three corresponding sample dataframes, (df_element_columns, df_construct_columns, and df_long) are included in the package (see examples). See Detail section below for more info.

Usage

importDataframe(
  x,
  format = "element_columns",
  rmin = NULL,
  rmax = NULL,
  pole_sep = ":"
)

Arguments

x

A dataframe. See Detail section and examples for required format.

format

One of element_columns (default), construct_columns, or long. See corresponding sections below.

rmin, rmax

Min and max of rating scale.

pole_sep

Character(s) to seperate the constructs poles (defaults to a colon) for format construct_columns. Without a separator, constructs are used as right poles, all left poles will be NA.

Value

A 'repgrid“ object.

Format element_columns

In this format, each element has a separate column, and each row contains the ratings 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 columns names 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()). See sample dataframe df_element_columns.

Format construct_columns

In this format, each construct has a separate column, and each row contains represents element. This format often results when summarising data (see examples). It looks like this:

The first column is named elements followed by the constructs. The construct poles are separated by a colon by default (see arg pole_sep). The rows below contain the elements' entries (element name, ratings). The min and max of the rating scale should be passed explicitly via the args rmin and rmax. See sample dataframe df_construct_columns.

elements left_pole_1:right_pole_1 left_pole_2:right_pole_2 left_pole_3:right_pole_3
element_1 1 5 3
element_2 3 1 1
element_3 4 2 5

Format long

The long format gets its name from the fact, that it has less columns, but many more 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 sample dataframe df_long.

See Also

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

Examples

# dataframe with elements as columns (preferred way)
importDataframe(df_element_columns)

# dataframe with constructs as columns
importDataframe(df_construct_columns, format = "construct_columns", rmin = 1, rmax = 5)

# dataframe with long format
importDataframe(df_long, format = "long", rmin = 1, rmax = 5)

[Package OpenRepGrid version 0.1.18 Index]