I have the following data.frame df1 with factor fac1 that I have created in R and I pass it as an argument in a Rcpp function. The requested task is to get all the factor levels inside an Rcpp function and use them.
fac1 <- factor(x = sample(x = 1:5,size = 100,replace = T),labels = paste0("D",1:5))
var1 <- sample(x = 1:20,size = 100,replace = T)
fac2 <- factor(x = sample(x = 1:12,size = 100,replace = T),labels = paste0("M",1:12))
df1 <- data.frame(fac1,var1,fac2)