Martin Møller Skarbiniks Pedersen
2017-Dec-03 19:04 UTC
[R] Rcpp, dyn.load and C++ problems
On 3 December 2017 at 05:23, Eric Berger <ericjberger at gmail.com> wrote:> > Do a search on "Rcpp calling C++ functions from R" >Thanks. However search for "Rcpp calling C++ functions from R" gives a lot of result but I think some of them are outdated and others don't agree with each other. Can you point to a specific good on-line guide for me? Regards Martin [[alternative HTML version deleted]]
I would go to the source, in this case Dirk Eddelbuettel's (I hope I
spelled it correctly) documentation for Rcpp:
http://dirk.eddelbuettel.com/code/rcpp/Rcpp-attributes.pdf
Note that you need to do
sourceCpp("logistic_map.cpp")
in R instead of building and dyn.load()-ing the object.
HTH,
Peter
On Sun, Dec 3, 2017 at 11:04 AM, Martin M?ller Skarbiniks Pedersen
<traxplayer at gmail.com> wrote:> On 3 December 2017 at 05:23, Eric Berger <ericjberger at gmail.com>
wrote:
>
>>
>> Do a search on "Rcpp calling C++ functions from R"
>>
>
> Thanks. However search for "Rcpp calling C++ functions from R"
gives a lot
> of result but I think
> some of them are outdated and others don't agree with each other.
>
> Can you point to a specific good on-line guide for me?
>
> Regards
> Martin
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
On 3 December 2017 at 11:08, Peter Langfelder wrote:
| I would go to the source, in this case Dirk Eddelbuettel's (I hope I
| spelled it correctly)
You did. Take a point :)
| documentation for Rcpp:
|
| http://dirk.eddelbuettel.com/code/rcpp/Rcpp-attributes.pdf
Yup. And
RShowDoc("Rcpp-attributes", package="Rcpp")
in R is even easier.
On 3 December 2017 at 13:19, Dirk Eddelbuettel wrote:
| 0) Wrong list. Rcpp has its down, rcpp-devel, and I basically do not read
| this and would have missed this were it not for luck.
"R has its own list, rcpp-devel" is what I meant to write. For
completeness,
we can also test on the command-line as Martin and what I do a lot myself:
edd at bud:~$ r -lRcpp -e'sourceCpp("/tmp/mmsp.cpp")'
R> res <- compute_values_cpp()
R> str(res)
Attaching package: ?utils?
The following objects are masked from ?package:Rcpp?:
.DollarNames, prompt
List of 2
$ x: num [1:100000] 199 362 118 302 262 ...
$ y: num [1:100000] 20 40 14.3 39.5 36.9 ...
You have mail in /var/mail/edd
edd at bud:~$
That uses littler which I like, Rscript is almost the same (but has no -l
switch for libraries and fails to load the methods package which we sometimes
need).
Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org