cpp_fast_factor: Fast Factorize Vector

View source: R/RcppExports.R

cpp_fast_factorR Documentation

Fast Factorize Vector

Description

Makes factor with Rcpp

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)

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).

Source

adaptation from Kevin Ushey code https://gallery.rcpp.org/articles/fast-factor-generation/


IFC documentation built on Sept. 14, 2023, 1:08 a.m.