flag_resp {resquin}R Documentation

Flag respondents based on response quality indicators

Description

Flag respondents with one or more flagging expression.

Usage

flag_resp(x, ...)

Arguments

x

A data frame containing response quality indicators. Each column should be one response quality indicator. Each row should be the value of the response quality indicator of a respondent.

...

Flagging expressions. See details.

Details

flag_resp() works very similar to the popular dplyr::filter() function. However, instead of filtering data, flag_resp() returns a data frame of T and F values, representing which respondents are flagged.

As the first argument, you provide a data frame of response quality indicators, where each column represents one response quality indicator and each row represents one respondent. As the second argument you provide one ore more logical statements to flag respondents. For example:

Note that flag_resp() is not restricted to functions from the resquin package. You can supply any numerical column in the data frame x. This opens the possibility to compare flagging strategies based on response quality indicators across packages and functions.

Use the summary() function on the results to compare flagging strategies.

For more details see the vignette: vignette("flagging_respondents", package = "resquin")

Value

A data frame containing one column per flagging strategy and the same number of rows asx. Each column contains T and F flags per respondents. An additional id column is added as the first column if a column named id is present in x.

Examples

res_dist_indicators <- resp_distributions(nep) # Create indicator data frame

flagged_respondents <- flag_resp(res_dist_indicators,
                                 ii_mean > 3, # Flagging strategy 1
                                 ii_sd < 2, # Flagging strategy 2
                                 ii_mean > 3 & ii_sd > 2) # Flagging strategy 3
flagged_respondents # A data frame with three columns, each corresponding to one flagging strategy
summary(flagged_respondents) # quickly compare flagging strategies


[Package resquin version 0.1.1 Index]