I need some guidance in calling a newly compiled version of rpart. I am
using rpart3 for windows and Microsoft Visual C+ 6.0. I have created a
project (to create a DLL) in Visual 6.0, added the rpart3 source code and
created a definition file that includes all of the function calls in
rpart3. Then, I compile (without making any changes) the code to create a
S.dll file. The DLL file is created without any errors.
In Splus 6.0, I load my dataset and dll
(dyn.open("C:/temp/rpart3/S.dll")). I try to call the newly compiled rpart
with the following statement:
test1_.C("s_to_rp",
Surv(tlfup,sur)~(trt>1)+pnod+nucgr+mcsiz,x=T,y=T)
I get the following message:
> test1
Problem: Object "test1" not found, while calling subroutine
Use traceback() to see the call stack
Am I not making the proper function call? I thought that s_to_rp is the
function that I should call but I guess I am wrong. If I do the above
statement with rpart library loaded
(test1_rpart(Surv(tlfup,sur)~(trt>1)+pnod+nucgr+mcsiz,x=T,y=T)), it works.
To test the dll that I created, I added a simple function to rpart.c:
void rsum(double* x, int* pn, double* mean, double* stdv)
{
int n= *pn,i,j;
double sum=0, sqrsum=0;
for (i=0;i<n;i++)
{
sum += x[i];
}
*mean = sum/n;
for (j=0;j<n;j++)
{
sqrsum += ((x[j]- *mean)*(x[j]-*mean));
}
*stdv = sqrt(sqrsum/(n-1));
}
I compiled the code and created a new S.dll. I was able to get this
function to work with the following code in Splus:
y_pnod
z_0
x_0
x_.C("rsum",as.double(y),as.integer(402), as.double(x),
as.double(z))[[3]]
So the problem does not seem to be the DLL. Obviously, the problem is in
my call statement. Could anyone supply me with an example of how I could
call this newly compiled rpart? Sorry for the novice question but I have
not come across this information or I missed it. Any guidance would be
greatly appreciated. Thank you.
Scott Dean
|