Makes factor with Rcpp
an IntegerVector, with attributes "levels" being the non-NA unique value(s) found and "lvs" the total number of unique values found (including NA).
a SEXP only NILSXP, LGLSXP, INTSXP, REALSXP, STRSXP, RAWSXP are handled.
a bool specifying if NA should be returned as NA or if they should be attributed a unique integer.
returned object should not be of class `factor` so has to prevent malformed factor' error when printing the result in R.
For this reason, it is aimed to be wrap in an R function to handle factor class / handleNA balance.
e.g. either:
- structure(cpp_fast_factor(df, TRUE), class = "factor"), or,
- structure(cpp_fast_factor(unclass(df), FALSE), levels = NULL)