Samuel Kemp wrote:
> Hi,
>
> I have written the following R function.....
>
> GT <- function(data, p)
> {
> if(!is.loaded(symbol.C("runGT")))
>
>
dyn.load("/home/sekemp/Documents/RFiles/GammaProject/Test/GammaImproved2.so")
>
> dim <- length(data)
> M <- length(data[,dim])
> reconstruct <- array(dim=c(M,dim))
> for(i in 1:(dim-1))
> {
> reconstruct[,i] <- data[,i]
> }
> outputs <- array(data[,dim])
> inputs <- array(as.matrix(dist(reconstruct,
method="euclidean",
> diag=TRUE, upper=TRUE)), dim=c(M,M))
> overall <- .C("runGT",
> as.double(inputs),
> as.double(outputs),
> as.integer(M),
> as.integer(p),
> rd = double(p),
> rg = double(p))
> deltas <- overall$rd
> gammas <- overall$rg
> GT <- data.frame(deltas, gammas)
> return(GT)
> }
>
> When I use the function it returns the correct results. However, when I
> call the function for a second (3rd, 4th, etc) time it runs OK but does
> not return the correct result.
>
> I am using R on the latest version of Red Hat Linux.
>
> Does anyone have any ideas on a fix for this problem????
Some hints:
What is "overall"? Where do you get that variable from? Is it chnaged
in
the other environment?
What does your C level function? Does it use random numbers or do you
change values in R from this C level function?
You have to debug your function youself, since nobody else can reproduce
your examples!
Uwe Ligges
> Cheers,
>
> Sam.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html