On Fri, Nov 16, 2007 at 03:49:09PM -0500, Charles Danko wrote: > Hello, > > Quick question. > > I have written a C function - I would like to make it return two vectors to > the R environment - one STRSXP vector, and one INTSXP vector. Is this > possible/ easy to do using the API? > > I looked, but could not find the answer to this question in the "Writing R > Extensions" guide.
Yes, it's really quite reasonable to do, although it's not documented in detail in the R-extensions manual. As stated earlier, this will only work with .Call and SEXP functions where you can handle R objects within C. In Section 5.9 "Evaluating R expressions in C" it has an example using lists in C. Basically, lists are VECSXP objects so you can search for that in R-exts. Also, I would recommend looking at 5.7.6 "Handling lists" and the function: SEXP getListElement(SEXP list, char *str) You should look for that, and then grep the source files for examples. If you don't have grep to search the files, then I would recommend the R gonzui site: http://rgonzui.nakama.ne.jp/ Personally, I found the source code for det() to be a useful example, you can search for that on R gonzui. Good Luck ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel