Skip to content
Prev 23995 / 398502 Next

dyn.load and c-function

"Jeff D. Hamann" <jeff_hamann at hamanndonald.com> writes:
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]]