Brian J. Knaus

Brian J. Knaus’s blog about genomics and biology.

Getting started with Rcpp

A colleague recently asked about getting started using Rcpp. After I sent the e-mail I thought that information may be of use to others. So I decided to blog about it. Rcpp is a package on CRAN that facilitates an interface between R and C++. It includes data structures that allow for easy sharing of data between the two languages. Because writting C++ code is usually more challenging than writing R code you should probably reserve it for tasks that you will repeat. Read more →

A minimal Rcpp and Roxygen2 package

I maintain an R package or two. The R universe includes a lot of nice tools that perform ‘magic’ to help my job as a developer easier. Sometimes, this magic breaks, which leaves me at a loss. My best path forward involves creating a new, minimal, package and attempting to rebuild the package. Because of the stated dependencies, this minimal package requires: roxygen2 Rcpp This repository describes how I build this minimal package. Read more →

Header files in Rcpp

In C++ you can create functions in order to help organize your code. This is helpful as your project grows or if you have a task that is performed by a function that several other functions may call. However, the functions you create are only visible to the other funcitons that are contained in a single source file. As your project grows, you may want to distribute your functions among several files. Read more →

R 3.4.1 personal library location

R 3.4.1 ‘Single Candle’ was released on June 30, 2017. Our group is preparing to provide an R workshop at our societal meeting this summer, so I’m tryingot keep up to date with the R releases. Installation on my work Ubuntu 16.04 LTS machine appeared to go smoothly. However, upon trying to install packages I received the following error. Warning in install.packages(update[instlib == l, "Package"], l, contriburl = contriburl, : 'lib = "/usr/lib/R/site-library"' is not writable Would you like to use a personal library instead? Read more →

Reproducing a clang-UBSAN issue

My R package, vcfR Version 1.5.0, is currently reporting a clang-UBSAN issue. I’ve described how to geet a Docker image with clang-UBSAN up and running here. Once we have the image up and running we’ll want to install package dependencies. First, pandoc is needed to render markdown and qpdf is used to check pdfs. apt-get update apt-get install pandoc qpdf Then we can install R packages. R -e 'install.packages(c("ape", "dplyr", "knitr", "poppr", "Rcpp", "memuse", "pinfsc50", "rmarkdown", "testthat", "tidyr", "vegan", "viridisLite"), dependencies = TRUE, lib = "/usr/local/lib/R/site-library")' Build and test our package. Read more →