Anyone writing code for use in data processing systems needs to have a well thought-out protocol for generating error messages and logs. When a complex pipeline breaks, good logs and recognizable error messages are key to debugging the problem. This post describes improvements to the MazamaCoreUtils package that help you create systematic error messages that can be better handled by calling functions.
Continue readingTag: R
Easy Rolling Means with MazamaRollUtils
Our goal in creating a new package of C++ rolling functions is to build up a suite of functions useful in environmental time series analysis. We want these functions to be available in a neutral environment with no underlying data model. The functions are as straightforward to use as is reasonably possible with a target audience of data analysts at any level of R expertise.
Continue readingBeautiful Maps with MazamaSpatialPlots
Many of us have become addicted to The NY Times COVID maps — maps of US state or county level data colored by cases, vaccinations, per capita infections, etc. While recreating maps like these in R is possible, it is disappointingly difficult. The just released MazamaSpatialPlots R package takes a first stab at remedying this situation.
Continue readingUsing R — Packaging a C library in 15 minutes
Yes, this post condenses 50+ hours of learning into a 15 minute tutorial. Read ’em and weep. (That is, you read while I weep.)
Continue readingUsing R — Calling C code with Rcpp
In two previous posts we described how R can call C code with .C() and the more complex yet more robust option of calling C code with .Call(). Here we will describe how the Rcpp package can be used to greatly simplify your C code without forcing you to become expert in C++.
Continue readingUsing R – .Call(“hello”)
In an introductory post on R APIs to C code, Calling C Code ‘Hello World!’, we explored the .C() function with some ‘Hello World!’ baby steps. In this post we will make a leap forward by implementing the same functionality using the .Call() function.
Continue readingUsing R – Calling C code ‘Hello World!’
One of the reasons that R has so much functionality is that people have incorporated a lot of academic code written in C, C++, Fortran and Java into various packages. Libraries written in these languages are often both robust and fast. If you are using R to support people in a particular field, you may be called upon to incorporate some outside code into your R environment. Unfortunately, much of the documentation on how to do this is written at a very high level. In this post we will distil some of the available information on calling C code from R into three “Hello World” examples.
Continue readingData Structures – Tabular vs. Relational
With enough effort it is possible to fit a square peg into a round hole. But we have all learned — sometimes more than once — that it is much easier if peg and hole have the same shape.
Continue readingLogging and error handling in operational systems
Operational systems, by definition, need to work without human input. Systems are considered “operational” after they have ben thoroughly tested and shown to work properly with a variety of input.
However, no software is perfect and no real-world system operates with 100% availability or 100% consistent input. Things occasionally go wrong – perhaps intermittently. In a situation with occasional failures it is vitally important to have good logging and error handling. The MazamaCoreUtils R package helps with these tasks.
Continue readingWhen k-means clustering fails
Letting the computer automatically find groupings in data is incredibly powerful and is at the heart of “data mining” and “machine learning”. One of the most widely used methods for clustering data is k-means clustering. Unfortunately, k-means clustering can fail spectacularly as in the example below.
Continue reading