manip_factor_2_numeric {easyalluvial} | R Documentation |
converts factor to numeric preserving numeric levels and order in character levels.
Description
before converting we check whether the levels contain a number, if they do the number will be preserved.
Usage
manip_factor_2_numeric(vec)
Arguments
vec |
vector |
Value
vector
See Also
Examples
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")))
[Package easyalluvial version 0.3.2 Index]