R/informed_consent.R

Defines functions informed_consent

Documented in informed_consent

#' Informed Consent Filter
#' 
#' One of the best practices in data collection is including and informed consent question.
#' With this function you can automatically filter out rows where participants did not explicitly consent to their data being used.
#'
#' @param dataframe A dataframe of data collected with 'WEXTOR'
#' @param varname character. Variable name of informed consent variable. Defaults to "informedconsent".
#' 
#' @importFrom stats na.omit
#'
#' @returns Returns data with cases filtered out that did not check the informed consent box
#' @export
#' @examples
#' 
#' data <- data.frame(informedconsent = c("checked", "not checked", "checked"))
#' informed_only <- informed_consent(data) 
#' 
informed_consent <- function(dataframe, varname = "informedconsent"){
  
  new <- dataframe[dataframe[varname] == "checked", ] |> na.omit()
  new
}

Try the rextor package in your browser

Any scripts or data that you put into this service are public.

rextor documentation built on May 21, 2026, 5:09 p.m.