# Use package-internal list of oTree data frames
oTree <- gmoTree::oTree
# Create a new variable
oTree$survey$younger30 <- ifelse(oTree$survey$player.age < 30, 0, 1)
# Assign the variable younger30 to all_apps_wide
oTree2 <- assignv_to_aaw(
oTree = oTree,
app = "survey",
variable = "younger30",
newvar = "younger30")
# Show the new variable in the all_apps_wide data frame
oTree2$all_apps_wide$younger30
# Check the position of the new variable
match("younger30",names(oTree2$all_apps_wide))
# Place the new variable immediately after the "survey.1.player.age" variable
oTree2 <- assignv_to_aaw(oTree,
app = "survey",
variable = "younger30",
newvar = "younger30",
resafter = "survey.1.player.age")
# Show the new variable in the all_apps_wide data frame
oTree2$all_apps_wide$younger30
# Show the position of the new variable
match("younger30", names(oTree2$all_apps_wide))
Run the code above in your browser using DataLab