Tag Archives: R

17Nov/16

Where’s Waldo? Here he is!


Yesterday, I came across a nice article untitled “Here’s Waldo: Computing the optimal search strategy for finding Waldo“, written by Randal S. Olson. I used the data he shared to apply a correction to the kernel density estimation of Waldo’s location.

In this article, Randal explains that he has devoted some time to try to compute the optimal search strategy for finding Waldo. To that end, he has used some machine learning techniques.
From an image provided by Slate (Here’s Waldo, 2013, by Ben Blatt), Randal S. Olson retrieved the coordinates of 68 different locations of Waldo, and kindly shared the data afterwards.

[…]

03Nov/14

French dates in R – From Mac OS to Windows

Station Clock - By derivative work: FischX (talk) Station_Clock.jpg: User:JuergenG, User:AlMare (Station_Clock.jpg) [CC-BY-SA-2.5-2.0-1.0 (http://creativecommons.org/licenses/by-sa/2.5-2.0-1.0) or CC-BY-SA-2.5-2.0-1.0 (http://creativecommons.org/licenses/by-sa/2.5-2.0-1.0)], via Wikimedia Commons
The other day during my R lecture, something I did not expect happen… I should have known, or at least guess that it would not work… But I wanted to believe it would. When I gave examples on how to read both English and French formatted dates in R, what was working perfectly on Mac OS X did not on Windows Seven. The example was the following:

d_char_fr <- "Mer 04 Fév 2015"
d_char <- "Wed 04 Feb 2015"
as.Date(d_char_fr, format = c("%a %d %b %Y"))
as.Date(d_char, format = c("%a %d %b %Y"))
30Oct/14

Coordinates of “hot-spots”


Last week I uploaded a note about the paper @freakonometrics and I have submitted again after we added quite a few revisions. We have already made available most of the R code to reproduce our applications (on this GitHub repository). However, we did not share our method to obtain the coordinates of the “hot-spots” areas

10Nov/13

Scale bar and North arrow on a ggplot2 map using R

After some research on the Internet, I gave up trying to find an R function to add a scale bar and a North arrow on a map, using ggplot().
So, I would like to present you what I have come up with.

The idea is really basic : we create two polygons for the scale bar, we add some text above, and we draw an arrow. That’s it. The only tricky thing here, is the way to obtain the coordinates of each element. An easy solution is to use the gcDestination function, from the maptools package.