From ripley at stats.ox.ac.uk  Fri Apr 15 08:20:59 2005
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Fri Apr 15 08:21:10 2005
Subject: [Rd] dynamic array output by .C
In-Reply-To: <58618a62050414150165aae64@mail.gmail.com>
References: <58618a6205041414062f07d2a8@mail.gmail.com> 
	<Pine.LNX.4.61.0504142212070.14473@gannet.stats>
	<58618a62050414150165aae64@mail.gmail.com>
Message-ID: <Pine.LNX.4.61.0504150719460.19992@gannet.stats>

On Thu, 14 Apr 2005, Tib wrote:

> from the examples of Writing R Extensions,  I see one still has to
> declare the size of arrays by NEW_NUMERIC(n) or
> allocVector(REALSXP,n), how can I extend arrays?
>
> I know this question is a little specific, but it would be a lot
> helpful if anyone can give me a  quick question. Thanks

Use lengthgets().

> On 4/14/05, Prof Brian Ripley <ripley@stats.ox.ac.uk> wrote:
>> On Thu, 14 Apr 2005, Tib wrote:
>>
>>> Greetings,
>>>
>>> I am building a stochastic simulation model in a C++ shared library
>>> for R. My model will generate a random number of new observations and
>>> also delete some old observations, however, the numbers cannot be
>>> predicted before the computation engine runs. For simplicity, I am
>>> trying to control my programming at the second stage (pure C++ for R).
>>> It seems .C accepts fixed size of arrays as input (also ouput), can I
>>> modify size of array for deleting old and adding new observations in
>>> .C?
>>
>> No, but .Call can.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


[Rd] dynamic array output by .C
Prof Brian Ripley