dyn.load and c-function
"Jeff D. Hamann" <jeff_hamann at hamanndonald.com> writes:
tf2 <- function( a, b, c )
.C("testfunc2",
as.integer(a),
as.double(b),
as.integer(c),
as.double(d) )[[4]]
I get an "Object d not found" error...
how would I write the R part so that I can call my function the way I want
to?
Your C function assumes that d (or "result" as you call it on the
other side) exists with the relevant length. So you need to create it:
tf2 <- function( a, b, c ){
d <- double(length(a))
.C("testfunc2",
as.integer(a),
as.double(b),
as.integer(c),
d)[[4]]
}
or just
tf2 <- function( a, b, c )
.C("testfunc2",
as.integer(a),
as.double(b),
as.integer(c),
double(length(a)))[[4]]
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._