R code

Data Visualization with R (used in my Data Exploration and Visualization with R course)

ggplot2 Introduction

Fixed Effects Models in R

fixed effects.r

R, Rcpp, and Armadillo

Rcpp makes it very simple to connect C++ to R. For more information are available here: High performance functions with Rcpp

Armadillo is a C++ linear algebra library, aiming towards a good balance between speed and ease of use. RcppArmadillo acts as a bridge between Rcpp and Armadillo, allowing the programmer to write code using Armadillo classes that integrate seemlessly with R via Rcpp.

In the past, I have used or written a few C++ code used together with Rcpp and RcppArmadillo that generate random numbers in R. These random number generators seem to perform better (in terms of speed) than R's built-in functions, especially for MCMC draws. To use these functions from within R, you need to use both the Rcpp and RcppArmadillo packages, and use sourceCpp() to references these .cpp files.

  • rmvnormArma.cpp: generating random numbers from multivariate normal distribution

  • rtnorm.cpp: generating random numbers from truncated normal distribution

  • rwishArma.cpp: generating random numbers from Wishart distribution

  • kronC.cpp: calculating Kronecker product