assignv {gmoTree}R Documentation

Assign a variable from all_apps_wide

Description

Assign a variable from all_apps_wide to the other app data frames.

Usage

assignv(oTree, variable, newvar)

Arguments

oTree

A list of data frames that were created by import_otree().

variable

Character. The variable in the all_apps_wide data frame that should be assigned to all other apps.

newvar

Character. The name of the newly created variable.

Value

This function returns a duplicate of the original oTree list of data frames but with an additional column in all data frames. The additional column contains data from the specified variable found in all_apps_wide.

Examples

# Use package-internal list of oTree data frames
oTree <- gmoTree::oTree

# Assign variable "survey.1.player.gender" and name it "gender"
oTree <- assignv(oTree = oTree,
                 variable = "survey.1.player.gender",
                 newvar = "gender")

# Show the new variable in some of the other app data frames
oTree$dictator$gender
oTree$chatapp$gender

# The variable is now duplicated in app "survey" because it is obtained from
# there (This can be avoided by naming the new variable the same as the old
# variable)
oTree$survey$gender
oTree$survey$player.gender

# In app "all_apps_wide," the variable is also there twice (This can be
# avoided by naming the new variable the same as the old variable)
oTree$all_apps_wide$gender
oTree$all_apps_wide$survey.1.player.gender

[Package gmoTree version 1.0.1 Index]