manip_factor_2_numeric | R Documentation |
before converting we check whether the levels contain a number, if they do the number will be preserved.
manip_factor_2_numeric(vec)
vec |
vector |
vector
str_detect
fac_num = factor( c(1,3,8) ) fac_chr = factor( c('foo','bar') ) fac_chr_ordered = factor( c('a','b','c'), ordered = TRUE ) manip_factor_2_numeric( fac_num ) manip_factor_2_numeric( fac_chr ) manip_factor_2_numeric( fac_chr_ordered ) # does not work for decimal numbers manip_factor_2_numeric(factor(c("A12", "B55", "10e4"))) manip_factor_2_numeric(factor(c("1.56", "4.56", "8.4")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.