epi_clean_cond_chr_fct: Check if column is character or factor

View source: R/epi_clean_cond_chr_fct.R

epi_clean_cond_chr_fctR Documentation

Check if column is character or factor

Description

Check if column is character or factor (TRUE). Useful when extracting columns from a large data frame using dplyr (ie get all character and factor columns)

Usage

epi_clean_cond_chr_fct(col = NULL)

Arguments

col

column header. This will be passed to is.character(col) and is.factor(col)

Value

boolean TRUE/FALSE indicating whether column passed is type character or factor

Author(s)

Antonio Berlanga-Taylor <\url{https://github.com/AntonioJBT/episcout}>

See Also

epi_clean_cond_numeric, epi_clean_cond_date, epi_clean_class_to_factor, epi_clean_count_classes, is.character, is.factor.

Examples

## Not run: 
library(dplyr)
library(tibble)
col_chr <- data.frame(
  "chr1" = rep(c("A", "B")),
  "chr2" = rep(c("C", "D"))
)
df_cont_chr <- as.tibble(cbind(df, col_chr))
df_cont_chr %>% select_if(~ epi_clean_cond_chr_fct(.))
epi_clean_cond_chr_fct(df_cont_chr[[2]]) # should be 'TRUE'
epi_clean_cond_chr_fct(df_cont_chr[, "x"]) # should be 'FALSE'

## End(Not run)


AntonioJBT/episcout documentation built on June 11, 2025, 7:26 p.m.