epi_clean_cond_chr_fct: Check if column is character or factor

Description Usage Arguments Value Author(s) See Also Examples

View source: R/epi_clean_cond_chr_fct.R

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

1

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 <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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## Not run: 
library(dplyr)
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 Nov. 7, 2019, 5:34 p.m.