Learn R Programming

OpenRepGrid (version 0.1.18)

importDataframe: 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 = ":"
)

Value

A `repgrid`` object.

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.

Format <code>element_columns</code>

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.

1element_1element_2element_3element_45preferred
left_pole_11534right_pole_1left
left_pole_23113right_pole_2right
left_pole_34251right_pole_3NA

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 <code>construct_columns</code>

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.

elementsleft_pole_1:right_pole_1left_pole_2:right_pole_2left_pole_3:right_pole_3
element_1153
element_2311
element_3425

Format <code>long</code>

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:

elementleft_poleright_poleratingpreferred_polerminrmax
element 1left pole 1right pole 11left15
element_2left pole 1right pole 15left15
element_3left pole 1right pole 14left15

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

Run this code
# 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)

Run the code above in your browser using DataLab