Description Usage Arguments Value Author(s) See Also Examples
View source: R/epi_clean_cond_chr_fct.R
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)
1 |
col |
column header. This will be passed to is.character(col) and is.factor(col) |
boolean TRUE/FALSE indicating whether column passed is type character or factor
Antonio Berlanga-Taylor <https://github.com/AntonioJBT/episcout>
epi_clean_cond_numeric
,
epi_clean_cond_date
,
epi_clean_class_to_factor
,
epi_clean_count_classes
,
is.character
,
is.factor
.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.