Skip to contents

drop_detect function detects participants who have dropped out of a survey. It identifies sequences of NA values up to the last survey question and pinpoints the column where the dropout occurred. It also provides the index of that column, enabling targeted analysis of dropout patterns.

Usage

drop_detect(data, last_col = NULL)

Arguments

data

A dataframe or tibble containing the survey data.

last_col

The index position or column name of the last survey item. This is optional and is used when there are additional columns in the data frame that are not part of the survey questions you are interested in.

Value

A dataframe or tibble where each row corresponds to a row in the original dataset. It contains three columns:

  • dropout: A logical indicating whether a dropout was detected for this row.

  • dropout_column: If dropout is TRUE, the name of the column where the dropout occurred.

  • dropout_index: If dropout is TRUE, the index (column number) where the dropout occurred.

See also

See vignette for detailed workflows and practical examples.

Examples

# Basic usage
drop_detect(flying, "location_census_region")
#> # A tibble: 1,040 × 3
#>    dropout_column     dropout dropout_index
#>    <chr>              <lgl>           <int>
#>  1 seat_recline       TRUE                3
#>  2 NA                 FALSE              NA
#>  3 NA                 FALSE              NA
#>  4 NA                 FALSE              NA
#>  5 NA                 FALSE              NA
#>  6 NA                 FALSE              NA
#>  7 NA                 FALSE              NA
#>  8 NA                 FALSE              NA
#>  9 switch_for_friends TRUE               15
#> 10 NA                 FALSE              NA
#> # ℹ 1,030 more rows