Nevermind about the boolean object, after thinking about it for 2 seconds, I figured it out. Just going to translate the boolean to an integer object with 1 representing true and 0=false and send that to C :P. -- View this message in context: http://www.nabble.com/Manipulating-R-objects-in-C%2B%2B-tf4249882.html#a12095136 Sent from the R devel mailing list archive at Nabble.com.
Jonathan Zhou
2007-Aug-10 17:35 UTC
[Rd] Convert multiple C strings into an R character vector
I was hoping someone could tell me how to convert multiple C character strings into an R character vector. Thanks, Jon -- View this message in context: http://www.nabble.com/Convert-multiple-C-strings-into-an-R-character-vector-tf4249882.html#a12095059 Sent from the R devel mailing list archive at Nabble.com.
Seth Falcon
2007-Aug-10 17:58 UTC
[Rd] Convert multiple C strings into an R character vector
Jonathan Zhou <jonathan.zhou at utoronto.ca> writes:> I was hoping someone could tell me how to convert multiple C character > strings into an R character vector.Here's a quick untested sketch: char **yourStrings; int numStrings = /* the length of yourStrings */; int i; SEXP cvect; PROTECT(cvect = allocVector(STRSXP, numStrings)); for (i = 0; i < numStrings; i++) { SET_STRING_ELT(cvect, i, mkChar(yourStrings[i])); } UNPROTECT(cvect); return cvect; + seth -- Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center BioC: http://bioconductor.org/ Blog: http://userprimary.net/user/