I am a bit confused about usage of R internal functions. I am able to send a char vector from C to R but not sure on how to send a vector of strings etc.
My code looks like this. <code> SEXP result = PROTECT(Rf_allocMatrix(STRSXP,s->n_rics,s->n_fields)); int i,j; for (i=0; i < s->n_rics; i++) { for (j=0; j < s->n_fields; j++) { std::string text = s->data[j][i]; result[j][i] = R_alloc( text.length(), sizeof(char)); //strcpy(result[j][i], text.c_str()); SET_STRING_ELT(result[j][i],0,Rf_mkChar(text.c_str())); } } // memcpy(result,s->data.ref(),s->n_fields*s->n_rics*sizeof(200)); UNPROTECT(1); return result; </code> Can someone please make me understand this usecase and how to resolve it? thanks, Alok -- View this message in context: http://r.789695.n4.nabble.com/how-to-return-a-matrix-of-strings-from-c-to-R-tp3900763p3900763.html Sent from the R devel mailing list archive at Nabble.com. ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel