From therneau at mayo.edu  Mon Feb 25 15:02:01 2013
From: therneau at mayo.edu (Terry Therneau)
Date: Mon, 25 Feb 2013 08:02:01 -0600
Subject: [Rd] Registering native routines
In-Reply-To: <5128873A.1030603@gmail.com>
References: <5127CE36.6070109@mayo.edu> <5128873A.1030603@gmail.com>
Message-ID: <512B6ED9.6010603@mayo.edu>

That was the correct direction: I changed the earler line to "routines <- list(Ccoxfit5a, 
..." and the the later to  .C(routnines[[1]]) and now it works as desired.

Terry T.

On 02/23/2013 03:09 AM, Duncan Murdoch wrote:
> On 13-02-22 2:59 PM, Terry Therneau wrote:
>> I'm working on registering all the routines in the survival package, per a request from
>> R-core.  Two questions:
>>
>> 1. In the coxph routine I have this type of structure:
>>        if (survival has 2 columns) routines <- c("coxfit5_a", "coxfit5_b", "coxfit5_c")
>>           else                     routines <- c("agfit5_a",  "agfit5_b",  "agfit5_c")
>>
>> .....
>>
>>       .C(routines[1], arg1, etc
>>
>> I tried replacing "routines" with a vector of native symbol references, but it doesn't 
>> work
>>
>> Error in .C(routines[1], as.integer(n), as.integer(nvar), as.double(y),  :
>>     first argument must be a string (of length 1) or native symbol reference
>
> I imagine routines is a list in this case, so you should be using routines[[1]] to 
> extract the element, rather than subsetting the list.
>
> Duncan Murdoch



[Rd] Registering native routines
Terry Therneau