Converting factors to numbers in R can be frustrating. Consider the following sitation: We have some data, and try to convert a factor (sex in tips, see below) to a numeric variable: library(tidyverse) library(sjmisc) # for recoding data(tips, package = "reshape2") glimpse(tips) #> Observations: 244 #> Variables: 7 #> $ total_bill <dbl> 16.99, 10.34, 21.01, 23.68, 24.59, 25.29, 8.77, 26…. #> $ tip <dbl> 1.01, 1.66, 3.50, 3.31, 3.61, …