Skip to contents

The list_assert_data() function takes a data.frame as an input and will assert if the data is correct. If it's not, it will tell you where changes need to be made to the initial data.frame (e.g. respondents to filter, values to change and more). For lists of bundles (results of list_read_data_bulk()) there is a list_assert_data_bulk() wrapper.

Usage

list_assert_data_bulk(data, demo, id, n_items)

list_assert_data(data, demo, id, n_items)

Arguments

data

A data.frame created with list_read_data() or a list created with list_read_data_bulk().

demo

A data.frame containing response_id column and variables that will be used as breaks in model. The order of the columns and order of the levels will determine the order of columns in the output of the list_render_sheets().

id

Quoted or unquoted name of column with respondent's id.

n_items

An integer(1). Number of non-sensitive (control) items in list experiment.

Value

A list with cleaned tibble from list_read_data() output (data), number of non-sensitive items (n_items) and tibble containing dropped responses id and reason for dropping (removed_responses). In the case of list_assert_data_bulk() the results will be stored as a list, where each element refers to single bundle.

Examples

library("dplyr")
data("list_experiment_toy")

## Create a data frame with demographic variables
### We select 3 categorical variables as demographic breaks and one artificial
### numeric variable just for the purpose of demonstration.

demo_toy <- list_experiment_toy %>%
  select("response_id", "d_party", "s_gender", "s_region") %>%
  mutate(num_var = rnorm(nrow(.), 3, 0.4))

## Assert the data
### First we need to read List Experiment data and pass the results
### to list_assert_data() along with demo data.

le_data_toy <- list_read_data_bulk(list_experiment_toy, "response_id")

### Then we pass the results to the list_assert_data_bulk() function
### along with the data frame with demographic variables

le_assert_data <- list_assert_data_bulk(
  le_data_toy, demo_toy, "response_id", 4L
)
#> 

#> 
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ── Asserting data for `bundle_1` ────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting Identifiers
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting groups
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting direct question
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting response question
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting demo variables
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Demo is data.frame with `response_id` column
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ✖ 35 respondents have at least one missing value in break variables - dropping them.
#> 
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> 
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ── Asserting data for `bundle_2` ────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting Identifiers
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting groups
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting direct question
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting response question
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ✖ 12 respondents from control group have response values that should not be available (other than integers from 0 to n_item) - dropping them.
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting demo variables
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Demo is data.frame with `response_id` column
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ✖ 35 respondents have at least one missing value in break variables - dropping them.
#> 
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> 
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ── Asserting data for `bundle_3` ────────────────────────────────────────────────────────────────────────────────────────────
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting Identifiers
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting groups
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting direct question
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting response question
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Asserting demo variables
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ℹ Demo is data.frame with `response_id` column
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m

#> 

#> ✖ 35 respondents have at least one missing value in break variables - dropping them.
#> 
#> Building packages ■■■■■■■■■■■■■■■■■■■■■             67% | ETA:  4m