I am using the R version 3.5.1 package sjmisc to perform recodes and produce reports.
Why is the value x = 44 incorrectly recoded into 5?
library(sjmisc)
X <- data.frame(x=c(44,14,0,1,4,6,10))
X <- X %>%
sjmisc::rec(x,
rec = "2:5=2 [2-5];6:10=3 [6-10];11:50=4 [11-50];51:max=5 [51+];else=copy",
as.num = FALSE)
print(X) # x = 44 should have x_r = 4
X %>% sjmisc::frq(x_r)
If the values in the column fall in all the ranges mentioned, it is working.
X %>%
sjmisc::rec(x,
rec = "2:5=2 [2-5];6:10=3 [6-10];11:50=4 [11-50];else=copy",
as.num = FALSE)
# A tibble: 7 x 2
# x x_r
# <dbl> <fct>
#1 44 4
#2 14 4
#3 0 0
#4 1 1
#5 4 2
#6 6 3
#7 10 3
It could be a bug