Blog Archives

Computing Maritime Routes in R

March 25, 2013
By
Computing Maritime Routes in R

Thanks to the attention my paper on the cost of Somali piracy has received, a lot of people have approached me to ask how I computed the maritime routes. It is not a very difficult task using R. The key ingredient is a map of the world, that can be rasterized into a grid; all

Read more »

R function: generate a panel data.table or data.frame to fill with data

October 25, 2012
By

I have started to work with R and STATA together. I like running regressions in STATA, but I do graphs and setting up the dataset in R. R clearly has a strong comparative advantage here compared to STATA. I was writing a function that will give me a (balanced) panel-structure in R. It then simply

Read more »

Removing Multibyte Characters from Strings

January 29, 2012
By

I was a bit annoyed by the error when loading a dataset that contains multi-byte characters. R basically just chokes on them. I have not really understood the intricacies of this, but it was basically just an annoyance and since I did not really use these characters in the strings containing them, I just wanted

Read more »

Microfinance Map of India – another go…

September 30, 2011
By
Microfinance Map of India – another go…

I gave it another go, trying to get a map that looks a bit nicer. This time, I tried to compute something like a density or intensity in a certain area. On the previous map, this was not visible very well. I used ggplot2 and a bit of R code, together with RGoogleMaps to produce the

Read more »

Microfinance in India: Getting a sense of the geographic distribution

September 3, 2011
By
Microfinance in India: Getting a sense of the geographic distribution

I am working on a review paper on microfinance in India and use data from the MIX market. Today, I was amazed by how quick I conjured a map of India with the headquarters of the microfinance institutions that report data to the MIX market depicted on that map. Ideally, I would have more geolocation

Read more »

R Function Binding Vectors and Matrices of Variable Length, bug fixed

August 19, 2011
By

Now this is something very geeky, but useful. I had to bind two matrices or vectors together to become a bigger matrix. However, they need not have the same number of rows or even the same row names. The standard cbind() functions require the vectors or matrices to be compatible. The matching is “stupid”, in

Read more »