Where do you run to? Map your Strava activities on static and Leaflet maps.

So, Strava’s heatmap made quite a stir the last few weeks. I decided to give it a try myself. I wanted to create some kind of “personal heatmap” of my runs, using Strava’s API. Also, combining the data with Leaflet maps allows us to make use of the beautiful map tiles supported by Leaflet and to zoom and move the maps around – with the runs on it, of course. So, let’s get started. First, you will need an access token for Strava’s API. I found all the necessary information for this in this helpful “Getting started” post. As soon as you have the token, you have access to your own data. Now, let’s load some packages and define functions for getting and handling the data. For the get.activities() function, I adapted code from here. library(httr)library(rjson)library(OpenStreetMap)library(leaflet)library(scales)library(dplyr)token <- “”get.coord.df.from.stream <- function…
Original Post: Where do you run to? Map your Strava activities on static and Leaflet maps.

Substitute levels in a factor or character vector

I’ve been using the ggplot2 package a lot recently. When creating a legend or tick marks on the axes, ggplot2 uses the levels of a character or factor vector. Most of the time, I am working with coded variables that use some abbreviation of the “true” meaning (e.g. “f” for female and “m” for male or single characters for some single character for a location: “S” for Stuttgart and “M” for Mannheim). In my plots, I don’t want these codes but the full name of the level. Since I am not aware of any super-fast and easy to use function in base R (let me know in the comments if there is one), I came up with a very simple function and put this in my .Rprofile (that means that it is available whenever I start R). I called it…
Original Post: Substitute levels in a factor or character vector

Visualisation of Likert scale results

I wrote a function to visualise results of Likert scale items. Please find the function below the post. Here is an example plot: The function is called ‘plot.likert’ and takes the following arguments: – vec: The vector with the raw results – possible.values: A vector with all the possible values. This is sometimes important if not all possible responses were…
Original Post: Visualisation of Likert scale results

Troubles with cell labels in mosaic plots… and how to solve them.

Today I want to write about a solution to a quite specific problem. Suppose, you want to label cells in your ‘vcd’ package mosaic plots in a custom way. For example, we might want to use cell labels which indicate “too much” or “too few” cases (given your expected values). Such labels might be “+” and “-” (and maybe “++”…
Original Post: Troubles with cell labels in mosaic plots… and how to solve them.

Do basic R operations much faster in bash [Slightly off-topic]

R is great, and you can do a LOT OF stuff with it. However, sometimes you want to do really basic stuff with huge or a lot of files. At work, I have to do that a lot because I am mostly dealing with language data that often needs some pre-processing. Most of these operations are done much, much faster…
Original Post: Do basic R operations much faster in bash [Slightly off-topic]