From osklyar at ebi.ac.uk  Sat Nov 17 01:53:11 2007
From: osklyar at ebi.ac.uk (Oleg Sklyar)
Date: Sat, 17 Nov 2007 00:53:11 +0000
Subject: [Rd] Returning vectors of two different data types back to
	R	environment (from C).
In-Reply-To: <8adccabf0711161249n763c3290o1ec4bab4bea1a104@mail.gmail.com>
References: <8adccabf0711161249n763c3290o1ec4bab4bea1a104@mail.gmail.com>
Message-ID: <1195260791.6220.4.camel@carbon>

SEXP x,y,res;
PROTECT(res = allocVector(VECSXP, 2));
SET_VECTOR_ELT(res, 0, x = allocVector(REALSXP, 20)); 
SET_VECTOR_ELT(res, 1, y = allocVector(INTSXP, 10)); 
// code with x,y goes here

UNPROTECT(1);
return res;

On Fri, 2007-11-16 at 15:49 -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.
> 
> Thanks very much for your help!
> Charles
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Returning vectors of two different data types back to R environment (from C).
Oleg Sklyar