[Rd] how to return a matrix of strings from c to R ?

Alok Jadhav alok.jadhav at credit-suisse.com
Thu Oct 13 09:20:54 CEST 2011

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.


                SEXP result =

		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());

//		memcpy(result,s->data.ref(),s->n_fields*s->n_rics*sizeof(200));
		return result;


Can someone please make me understand this usecase and how to resolve it?


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.

More information about the R-devel mailing list