delete_dropouts {gmoTree}R Documentation

Delete dropouts

Description

Delete the data of all participants who did not end the experiment at (a) certain page(s) and/or app(s).

Caution 1: This function does not delete cases from the original CSV and Excel files!

Caution 2: This function does not delete cases from custom export data frames if they do not have a variable named participant.code and a variable named session.code!

Caution 3: This function does not delete any data from the $Chats data frame! (As the interpretation of chat data depends on how participants engage with each other, the data must be deleted with more care than deleting data in other apps. Hence, this function does not delete data in this data frame. Please do this manually if necessary!)

Usage

delete_dropouts(
  oTree,
  final_apps = NULL,
  final_pages = NULL,
  saved_vars = NULL,
  inconsistent = NULL,
  reason = "ENC",
  info = FALSE
)

Arguments

oTree

A list of data frames created with import_otree().

final_apps

Character string or character vector. The name(s) of the app(s) at which the participants have to finish the experiment.

final_pages

Character string or character vector. The name(s) of the page(s) at which the participants have to finish the experiment.

saved_vars

Character string or character vector. The name(s) of variable(s) that need(s) to be stored in the list of information on deleted cases in $info$deleted_cases.

inconsistent

Character string. Should the function continue or be stopped if at least one participant has inconsistent end_pages, inconsistent end_apps, or both? To continue, type "yes", to stop the function, type "no".

reason

Character string. The reason for deletion that should be stored in the list of information on deleted cases in $info$deleted_cases.

info

Logical. TRUE if a brief information on the dropout deletion process should be printed.

Value

This function returns a duplicate of the original list of data frames but without the deleted cases.

It adds information on the deleted cases to $info$deleted_cases. (This list is also filled by other functions.)

In this list, you can find the following information:

It is important to note that if only the argument final_pages is set, this function does not distinguish between page names that reoccur in different apps.

If the columns end_app and end_page in the output are empty, these variables were not saved by oTree for the specific participants. This could be because empty rows were not deleted. This can be done by using the argument del_empty = TRUE when using import_otree().

Examples

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

# First, show some row numbers
print(paste(nrow(oTree$all_apps_wide), nrow(oTree$survey),
nrow(oTree$Time), nrow(oTree$Chats)))

# Delete all cases that didn't end the experiment on the page "Demographics"
# within the app "survey"
oTree2 <- delete_dropouts(oTree,
                         final_apps = c("survey"),
                         final_pages = c("Demographics"))

# Show row numbers again
print(paste(nrow(oTree2$all_apps_wide), nrow(oTree2$survey),
nrow(oTree2$Time), nrow(oTree2$Chats)))

# Delete all cases that didn't end the experiment on the page "Demographics"
# This page can be in any app
oTree2 <- delete_dropouts(oTree, final_pages = "Demographics")

# Show row numbers again
print(paste(nrow(oTree2$all_apps_wide), nrow(oTree2$survey),
nrow(oTree2$Time), nrow(oTree2$Chats)))

# Delete all cases that didn't end the experiment on
# any page in the app "survey"
oTree <- delete_dropouts(oTree, final_apps = "survey")

# Show row numbers again
print(paste(nrow(oTree2$all_apps_wide), nrow(oTree2$survey),
nrow(oTree2$Time), nrow(oTree2$Chats)))

# Get list of information on all deleted cases
# (If there is already a list, the new list is added to it!)
oTree2$info$deleted_cases

[Package gmoTree version 1.4.1 Index]