Skip to content

[Rcpp-devel] Favourite Rcpp examples?

8 messages · Dirk Eddelbuettel, Baptiste Auguie, Whit Armstrong

#
Finishing up slides for next week's one-day workshop on Rcpp [1], and I am
still looking for more good / simple examples and illustrations of Rcpp.  

Does anybody have any favourites to share?  I'd welcome replies both on-list
or off-list.

Thanks, Dirk


[1] http://dirk.eddelbuettel.com/blog/2011/04/06#rcpp_class_2011-04
5 days later
#
Hi,

Would RcppArmadillo be OK? I have a couple of functions / packages
using it with basic complex linear algebra calculations, together with
the original, slower R implementation.

Cheers,

baptiste
On 22 April 2011 04:15, Dirk Eddelbuettel <edd at debian.org> wrote:
#
On 27 April 2011 at 10:29, baptiste auguie wrote:
| Would RcppArmadillo be OK? I have a couple of functions / packages
| using it with basic complex linear algebra calculations, together with
| the original, slower R implementation.

That would be perfect, yes. Mind you it is getting late as the course is in
two days, but in a larger sense we _always_ want compelling examples to make
the Rcpp / RcppArmadillo examples better still.

Several folks kindly emailed me and spoke in favour of some sort of looped
example.  The example sent by Lance already lead to one (slightlt reworked)
blog post (at http://dirk.eddelbuettel.com/blog/2011/04/23#rcpp_for_varsims);
this uses RcppArmadillo to simulate a VAR(1) model. It has been added to the
SVN repo of RcppArmadillo as well and will be in the next release.

MCMC got a few mentions; I don't do much Bayesian analysis myself so I find
most examples too involved. I looked again at Whit's old example based on his
CppBugs code (on github).  But I did get my copy of Albert's 'Bayesian
Computation with R' out and worked one example of a basic (introductory)
Monte Carlo study (which I hope to blog about in a few days).

So a long-winded way of saying: Yes please!  Rcpp users have been kind with
suggestions; we added one example already and I am game for more. Show us
what you got ;-)

Cheers, Dirk
#
On 27 April 2011 10:56, Dirk Eddelbuettel <edd at debian.org> wrote:
OK, sorry I've just come back from a Easter trip; it'll be too late
for your original request but I'll tidy up some examples and post back
when they're ready.
By the way, have you considered setting up a sort of wiki so that
users could share tips and short recipes with Rcpp? I find that
archived emails are not always reliable as the code may change
substantially with time, and vignettes + unit tests are more
intimidating and not as convenient. ggplot2's wiki and stackexchange
seem to work well for this purpose nowadays.

Best,

baptiste
#
On 27 April 2011 at 11:17, baptiste auguie wrote:
| OK, sorry I've just come back from a Easter trip; it'll be too late
| for your original request but I'll tidy up some examples and post back
| when they're ready.

Cool, thanks.

| By the way, have you considered setting up a sort of wiki so that
| users could share tips and short recipes with Rcpp? I find that
| archived emails are not always reliable as the code may change
| substantially with time, and vignettes + unit tests are more
| intimidating and not as convenient. ggplot2's wiki and stackexchange
| seem to work well for this purpose nowadays.

I prefer vignettes and examples directories which can be built in automated
and batched fashion as additional build regression tests.

I do not plan to open a wiki, but if others want to go that route, why not.
As for stackoverflow et al: I am still not convinced people search that as
much.  I do add replies there, but it is still more one off-ish.

Whereas I do come back to examples/ which are in our packages; see e.g. just
this week with RInside.  Releasing worked and working example that way is my
clear preference.

Cheers, Dirk
#
I could probably show you the Gelman - Radon example in my MCMC framework.

Might be able to do a speed comparison w/ JAGS, but not sure if there
is sufficient time left for me to send and you to integrate the
example.

Let me know what you think.

-Whit
On Tue, Apr 26, 2011 at 6:56 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
#
On 26 April 2011 at 20:53, Whit Armstrong wrote:
| I could probably show you the Gelman - Radon example in my MCMC framework.
| 
| Might be able to do a speed comparison w/ JAGS, but not sure if there
| is sufficient time left for me to send and you to integrate the
| example.
| 
| Let me know what you think.

I bite, whether or not we get it done for this week or (most likely) not. I
actually did check out your cppbugs git archive. [ You have a bug that the
old example you posted now fails as your model class now takes four arguments
rather than three; throwing an arbitrary 1e4 for the added int argument works ]

Dirk
#
yes. thanks for reminding me.

I have a bunch of mcmc examples now. All using Rcpp, though probably
not coded in the best Rcpp style; you may remember I'm still using
this pathetic way to create the armadillo objects: "mat
X(REAL(XR),::Rf_nrows(XR),::Rf_ncols(XR));".

Anyway, those may prove useful to you, and hopefully in the process I
can clean up the RcppArmadillo conventions I'm using. I'll try to
package them up into a git repo later today.

-Whit
On Wed, Apr 27, 2011 at 12:47 AM, Dirk Eddelbuettel <edd at debian.org> wrote: