[Rd] Convert STRSXP or INTSXP to factor

Morgan Morgan morg@n@em@||box @end|ng |rom gm@||@com
Thu Jul 11 22:56:50 CEST 2019


Hi,

Using the R C PAI, is there a way to convert to convert STRSXP or INTSXP to
factor.

The idea would be to do in C something similar to the "factor" function
(example below):

> letters[1:5]
# [1] "a" "b" "c" "d" "e"

> factor(letters[1:5])
# [1] a b c d e
# Levels: a b c d e

There is the function setAttrib the levels of a SXP however when returned
to R the object is of type character not factor. Ideally what i would like
to return from the C function is the same output as above when the input is
of type character.

Please let me if you need more informations.
Thank you
Best regards
Morgan

	[[alternative HTML version deleted]]



More information about the R-devel mailing list