View source: R/epi_clean_cond_chr_fct.R
epi_clean_cond_chr_fct | R Documentation |
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)
epi_clean_cond_chr_fct(col = NULL)
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 <\url{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
.
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.