[Rd] append/concatenate an element to a list in C-language

From: Robert Castelo <robert.castelo_at_upf.edu>
Date: Thu, 18 Oct 2007 19:41:39 +0200

dear people,

i need to code a function in C working in R and receives two R SEXP objects as parameters, where one is a list and another is a vector of integers:

void f(SEXP list, SEXP vector) {


  return list;

and it should return the given list with the integer vector concatenated at the end (as the last element of the list). the list can be really big so i would not like to create a new list from scratch and copy all the elements, including the additional one. i'm also interested in knowing how should i properly handle protections of the SEXP objects when doing this.

i've been looking at the R source code for everything that has to do with CAR, CDR, CONS, and even found functions with promising names like listAppend or GrowList but i have not been able to figure this out nor i haven't been able to find any reference on how to do this by googling all around, so any help will be very much appreciated.

thanks a lot!!!


R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu 18 Oct 2007 - 17:46:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 25 Oct 2007 - 11:37:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.