MCPcopy Create free account
hub / github.com/apache/arrow / GetLevels

Method GetLevels

r/src/array_to_vector.cpp:762–776  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

760 }
761
762 SEXP GetLevels() const {
763 // R factor levels must be type "character" so coerce `dict` to STRSXP
764 // TODO (npr): this coercion should be optional, "dictionariesAsFactors" ;)
765 // Alternative: preserve the logical type of the dictionary values
766 // (e.g. if dict is timestamp, return a POSIXt R vector, not factor)
767 if (dictionary_->type_id() != Type::STRING &&
768 dictionary_->type_id() != Type::LARGE_STRING) {
769 cpp11::safe[Rf_warning]("Coercing dictionary values to R character factor levels");
770 }
771
772 SEXP vec = PROTECT(Converter::Convert(dictionary_));
773 SEXP strings_vec = PROTECT(Rf_coerceVector(vec, STRSXP));
774 UNPROTECT(2);
775 return strings_vec;
776 }
777};
778
779class Converter_Struct : public Converter {

Callers

nothing calls this directly

Calls 2

ConvertFunction · 0.50
type_idMethod · 0.45

Tested by

no test coverage detected