Learn R Programming

IFC (version 0.2.1)

cpp_fast_factor: Fast Factorize Vector

Description

Makes factor with Rcpp

Value

an IntegerVector, with attributes "levels" being the non-NA unique value(s) found and "lvs" the total number of unique values found (including NA).

Arguments

x

a SEXP only NILSXP, LGLSXP, INTSXP, REALSXP, STRSXP, RAWSXP are handled.

handleNA

a bool specifying if NA should be returned as NA or if they should be attributed a unique integer.

Details

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)