-
Recreational programming
I think programming, aka coding, is a fun activity. We are solving a problem subject to a set of constraints that can be time, memory, quantity of code, language, etc. Besides being a part of my work, coding is also a good distraction when doing it for the sake of it. In this type of […]
-
Fixing Rcpp warning in Mac OS
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.
-
Reading a folder with many small files
One of the tools we use in our research is NIR (Near-Infrared Spectroscopy), which we apply to thousands of samples to predict their chemical composition. Each NIR spectrum is contained in a CSV text file with two numerical columns: wavelength and reflectance. All files have the same number of rows (1296 in our case), which […]
-
Calculating parliament seats allocation and quotients
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 […]