Fixing Rcpp warning in Mac OS

Riccarton market, Christchurch

In Mac OS I was getting an annoying warning when compiling Cpp code via Rcpp in R:

Adding a file called Makevars in ~/.R defining FLIBS to the actual location of gfortran in my machine fixed the problem. In my case, Makevars only contains the following line:

That's it.

Reducing friction in R to avoid Excel

View of my desk in research mode, including friendly robot (Photo: Luis, click to enlarge).

When you have students working in a project there is always an element of quality control. Some times the results just make sense, while others we are suspicious about something going wrong. This means going back to check the whole analysis process: can we retrace all the steps in a calculation (going back to data… Continue reading Reducing friction in R to avoid Excel

Calculating parliament seats allocation and quotients

Gratuitous picture: tree on stilts (Photo: Luis, click to enlarge).

I was having a conversation about dropping the minimum threshold (currently 5% of the vote) for political parties to get representation in Parliament. The obvious question is how would seat allocation change, which of course involved a calculation. There is a calculator in the Electoral Commission website, but trying to understand how things work (and… Continue reading Calculating parliament seats allocation and quotients

Collecting results of the New Zealand General Elections

New Zealand Electoral Commission results website. It held really well in election night.

I was reading an article about the results of our latest elections where I was having a look at the spatial pattern for votes in my city. I was wondering how would I go over obtaining the data for something like that and went to the Electoral Commission, which has this neat page with links… Continue reading Collecting results of the New Zealand General Elections

Learning to code in R

It used to be that the one of the first decisions to make when learning to program was between compiled (e.g. C or FORTRAN) and interpreted (e.g. Python) languages. In my opinion these days one would have to be a masochist to learn with a compiled language: the extra compilation time and obscure errors are… Continue reading Learning to code in R