[R] accessing factor levels from C

Ott Toomet
2002-03-02T14:43:59Z

Hi,

I am trying to get information about factors from a C-program.  As I see,
the factors are basically integers with attribute ,,levels''.  But
unfortunately I am not been able to read the levels information.  I am
using:

SEXP variable, levels;

...

      variable = VECTOR_ELT( data_frame, j);
      switch( TYPEOF( variable)) {
      case INTSXP:
	if( isFactor( VECTOR_ELT( data_frame, j))) {
	  fvalue = INTEGER( variable)[i];
	  levels = STR_PTR( GET_LEVELS( variable));
	....


but the variable levels is not an array of strings as I expected.  I am
probably doing something in the wrong way but how would it be correct?

Thanks in advance,

Ott Toomet

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._