Blog Archives

Robust Estimators of Location and Scale

January 20, 2013
By
Robust Estimators of Location and Scale

First, the median_Rcpp function is defined to compute the median of the given input vector. It is assumed that the input vector is unsorted, so a copy of the input vector is made using clone and then std::nth_element is used to access the nth sorted element. Since we only care about accessing one sorted element of the vector...

Read more »

Custom as and wrap converters example

January 20, 2013
By
Custom as and wrap converters example

The RcppBDT package interfaces Boost.Date_Time with R. Both systems have their own date representations—and this provides a nice example of custom as<>() and wrap() converters. Here, we show a simplified example. We start with the forward declarations: #include <RcppCommon.h> #include <boost/date_time/gregorian/gregorian_types.hpp> // Gregorian calendar types, no I/O namespace Rcpp { // 'date' class boost::gregorian::date // ...

Read more »

Using Rcpp to access the C API of xts

January 19, 2013
By
Using Rcpp to access the C API of xts

The xts package by Jeff Ryan and Josh Ulrich is an immensely powerful tool that is widely used for timeseries work with R. Recently, the question about how to use it from Rcpp came up on StackOverflow and in a thread on the rcpp-devel list. In fact, xts has had an exposed API since 2008, but it...

Read more »

Using Rcpp to access the C API of xts

January 19, 2013
By
Using Rcpp to access the C API of xts

The xts package by Jeff Ryan and Josh Ulrich is an immensely powerful tool that is widely used for timeseries work with R. Recently, the question about how to use it from Rcpp came up on StackOverflow and in a thread on the rcpp-devel list. In fact, xts has had an exposed API since 2008, but it...

Read more »

Using the GSL to compute eigenvalues

January 18, 2013
By
Using the GSL to compute eigenvalues

Two posts showed how to compute eigenvalues using Armadillo and using Eigen. As we also looked at using theGNU GSL, this post will show how to conpute eigenvalues using GSL. As mentioned in the previous GSL post, we instantiate C language pointers suitable for GSL (here the matrix M). Those must be freed manually, as shown...

Read more »

Using the GSL to compute eigenvalues

January 18, 2013
By
Using the GSL to compute eigenvalues

Two posts showed how to compute eigenvalues using Armadillo and using Eigen. As we also looked at using theGNU GSL, this post will show how to conpute eigenvalues using GSL. As mentioned in the previous GSL post, we instantiate C language pointers suitable for GSL (here the matrix M). Those must be freed manually, as shown...

Read more »

Creating xts objects from source

January 17, 2013
By
Creating xts objects from source

A recent post showed how to access the attributes of an xts object. We used an xts object as these are powerful and popular—but any R object using attributed could be used to illustrate the point. In this short post, we show how one can also do the inverse in order to create an xts object at the C++...

Read more »

Creating xts objects from source

January 17, 2013
By
Creating xts objects from source

A recent post showed how to access the attributes of an xts object. We used an xts object as these are powerful and popular—but any R object using attributed could be used to illustrate the point. In this short post, we show how one can also do the inverse in order to create an xts object at the C++...

Read more »

Timing normal RNGs

January 16, 2013
By
Timing normal RNGs

In previous articles, we have seen that Rcpp can be particularly useful for simulations as it executes code at C++ speed. A very useful feature the API provided by R is the access to the R RNGs so that simulations at the C++ level can get precisely the same stream of random numbers as an R application would. But sometimes...

Read more »

Timing normal RNGs

January 16, 2013
By
Timing normal RNGs

In previous articles, we have seen that Rcpp can be particularly useful for simulations as it executes code at C++ speed. A very useful feature the API provided by R is the access to the R RNGs so that simulations at the C++ level can get precisely the same stream of random numbers as an R application would. But sometimes...

Read more »