I think is time to learning Rcpp! :-)

thank you   (Peter Dalgaard and Dirk Eddelbuettel )  by the examples!

the more simples are often more informatives...

cleber

Em 21/09/2015 12:36, Dirk Eddelbuettel escreveu:
peter dalgaard <pdalgd <at> gmail.com> writes:
C is call by value and k and res are pointers. You need a dereferencing
step or nothing with happen. Try
*res = *k + 1;
Or you use Rcpp which writes the glue code. Save the following into a file:


#include <Rcpp.h>

// [[Rcpp::export]]
int adder(int x, int y) {
   return x + y;
}

/*** R
adder(40, 2)
*/




Running this is as simple as sourcing it:

   R> Rcpp::sourceCpp("/tmp/adder.cpp")

   R> adder(40, 2)
   [1] 42
   R>

and it even runs the R snippet at the bottom.

Dirk

______________________________________________


---
Este email foi escaneado pelo Avast antivĂ­rus.
https://www.avast.com/antivirus

______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to