Learn R Programming

apollo (version 0.3.9)

apollo_longToWide: Converts data from long to wide format.

Description

Converts choice data from long to wide format, with one row per observation as opposed to one row per alternative/observation.

Usage

apollo_longToWide(longData, longToWide_settings)

Value

Returns a data.frame with the wide-format version of the data. An overview of the conversion and choice data is printed to screen. The returned choice column, choice_new, codes alternatives by their position in the order shown in the printed overview. #' @importFrom tibble is_tibble

Arguments

longData

data.frame. Data in long format.

longToWide_settings

List. Contains settings for this function. User input is required for all settings.

  • altColumn: Character. Name of column in long data that contains the names of the alternatives (either numeric or character).

  • altSpecAtts: Character vector. Names of columns in long data with attributes that vary across alternatives within an observation.

  • choiceColumn: Character. Name of column in long data that contains the choice indicator, coded 1 for the chosen alternative and 0 otherwise.

  • idColumn: Character. Name of column in long data that contains the ID of individuals.

  • obsColumn: Character. Name of column in long data that contains the observation index.