[Rcpp-devel] How to set stringsAsFactors=FALSE in Rcpp::DataFrame?

Asis Hallab asis.hallab at gmail.com
Tue Jul 22 12:59:18 CEST 2014


Dear Rcpp-Experts,

how can I get the equivalent of the R expression

my.df <- data.frame( …, stringsAsFactors=FALSE )

in Rcpp?

I have this code in Rcpp:
   …
   return( DataFrame::create(
      Named( "acc" )       = accsCol,
      Named( "ec" )        = ecCol,
      Named( "prot.acc" )  = protCol,
      Named( "term_type" ) = termTypeCol
    ) );

Calling the above from R, I realize, that the returned DataFrame's
columns are factors and not character-vectors, as I need them to be.

How to achieve this?
Should I just convert them in R itself, like in the following example?

for ( i in 1:ncol(my.df) ) {
  my.df[,i] <- as.character( my.df[,i] )
}

Or is there a better - and possibly more efficient - way to achieve this?

As always your help will be much appreciated.

Have a pleasant day and
Cheers!


More information about the Rcpp-devel mailing list