[Rcpp-devel] Newbie question: RInside from within a Inline/Rcpp cxxfunction
Dirk Eddelbuettel
edd at debian.org
Tue Oct 2 01:51:32 CEST 2012
Hi Dan,
On 2 October 2012 at 09:32, Dan.Pagendam at csiro.au wrote:
| Hi Dirk, Jeff,
|
| Thank you for your very helpful advice. I very much appreciate it. I think what I am really after is the ability to pass an Rfunction with Rcpp and not RInside at all. Apologies for missing this.
No worries. That should work, look e.g. at
examples/functionCallback/
which is a pretty clear (and stable, added ages ago) example.
There are other too if you need them.
And sorry about all the messed up grammar below. One day I'll start to
proofread emails before sending them...
Best, Dirk
|
| Cheers,
|
| Dan
|
| Dr Dan Pagendam
| OCE Postdoctoral Research Fellow
| CSIRO Mathematics, Informatics and Statistics
|
| Phone: +61 7 3833 5535 | Mobile: +61 4 3295 8551
| Email: Dan.Pagendam at csiro.au<mailto:Dan.Pagendam at csiro.au><mailto:Dan.Pagendam at csiro.au<mailto:Dan.Pagendam at csiro.au>> | http://www.csiro.au
| Postal Address: CSIRO Mathematics Informatics and Statistics, EcoSciences Precinct, PO Box 2583, Brisbane, QLD 4001
| Street Address: CSIRO Mathematics Informatics and Statistics, EcoSciences Precinct, 41 Boggo Road, Dutton Park, QLD 4102
|
|
|
| On 29/09/2012, at 12:38 AM, Dirk Eddelbuettel wrote:
|
|
| Hi Dan,
|
| Welcome to list.
|
| On 28 September 2012 at 13:48, Dan.Pagendam at csiro.au<mailto:Dan.Pagendam at csiro.au> wrote:
| | Bascially, I would like to write a cxxfunction in R using Rcpp and Inline so that I can execute my C++ code easily from within R. However, I'd like my C++ code comprising the cxxfunction to make use of the R language too. Is it possible for me to have my cxxfunction instantiate an object of class RInline within the C++ code? I guess what I'm getting at is, can I get R to call on a C++ function which in turn calls upon R code?
| |
| | I've looked at plenty of examples of code that use RInline and it seems that they are all just based around calling on R from with C++. This is making me wonder if what I am suggesting above is either plain dumb or just not possible.
|
| The latter.
|
| RIinside is for when you have a C++ program with 'int main(argc, argv)' to
| which you want to add R. [ I do not know how/where to make that more plain,
| but it seems I need to. Suggestions welcome. ]
|
| Rcpp is for when you want to extend R (which supplies its main() function).
|
| The two are _very_ distinct use cases.
|
| As Jeff P. just pointed out, you can call R functions from Rcpp code. That
| doesn't mean you should repeatedly -- there will be performance penalties.
| But for the occassional initialization or conversion or ... it is perfectly.
|
| It is also shown as part of the numerous examples that comes with Rcpp. Rcpp
| (and RInside) is pretty rich topic and there is lots of documentation. Keep
| looking. The list archives are also pretty fertile, and Google (via
| rseek.org<http://rseek.org>) is surely your friend.
|
| Dirk
|
| --
| Dirk Eddelbuettel | edd at debian.org<mailto:edd at debian.org> | http://dirk.eddelbuettel.com
|
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list