Category Archives: Uncategorized

A simple method for including Māori vowels in R plots

My Kiwi buddy Andrew Gormley was having trouble including the Māori language vowels with macrons (ā, ē, ī, ō, ū) in his R plots.

I wrote a quick R function “maorify.r” (code in the gist below), which provides a simple method for including these characters in R plots without having to type out the unicode in full each time. I’m sure there’s a simpler or more general purpose way to do this, but it does work. Perhaps it might be useful to anyone analysing Kiwi data with R.

tui

 

 

 

Advertisements

Tracking #365 papers with IFTTT

After vacillating for a little while, I’ve decided to get aboard the #365papers bandwagon on Twitter.

The idea behind this initiative (with credit for originating and popularising the idea largely attributable to Jacquelyn Gill and Meghan Duffy), is that researchers make a New Year’s resolution to read a scientific paper each day for a year, and tweet about each paper using the hashtag #365papers. By setting a target for reading of papers, participating researchers are encourage to read more, and to share interesting and topical papers with their followers on Twitter.

It’s now a week into 2016, so I’m a late starter. Maybe #365papers is a little ambitious for me, and I’ll only read #100papers or #52papers, but it seems like a fun and challenging idea I’d like to try.

Having a target is one thing, but how to keep track and measure progress towards the goal? Ideally I’d like to be able to keep track of what papers I have read and when I tweeted about them, and thereby track my progress towards my goal of 365 papers for the year. One simple solution would be to maintain a spreadsheet or database, and to manually enter the details of each paper when tweeting.  That’s how Meghan kept track of her #365papers progress, and it seems to work well. But perhaps there’s a better, more automated way to achieve the same result?

I’ve long been a fan of the web service IFTTT. Simply put, this free service provides a framework for linking together the different web services in intelligent ways, so as to automate common (and not-so-common) tasks. There’s an endless range of useful things you can do with IFTTT, from having it email you when you are mentioned on Facebook, to sending you an SMS when there is a storm warning for your area, or alerting you to interesting things to buy on Ebay.

The power of IFTTT is it’s integration with an enormous range of popular web services. Naturally enough, IFTTT includes integration with Twitter, and it also includes integration with Google Drive’s online spreadsheet software. To solve my #365papers tracking needs, I have set up an IFTTT recipe that monitors my twitter feed for tweets I have made that include the hashtag #365papers. When the IFTTT detects such a tweet, it copies the details of the tweet (time, date, text etc) into a new row on a google spreadsheet I have set up. The spreadsheet will now contain an automatic, up-to-date record of my #365papers  progress (or lack thereof!). If my lack of progress isn’t too embarrassing, I might share some details of how I go in another post.

Screenshot 2016-01-07 14.15.26

Details of my IFTTT recipe to track my #365papers progress

Screenshot 2016-01-07 16.22.45

….and the resulting spreadsheet on GoogleDrive

 

Things to learn this year

ggplot – I think this R package has the potential to make my graphics code more concise, quicker to write, and easier to modify and re-use. Hopefully a bit of time invested in learning the syntax will pay off in the form of nicer graphs and neater, easier to modify later code.

git – using a proper version control system should make tinkering with existing code, trying new things, and maintaining complex collections of code easier. Github will facilitate sharing code where desired.

Using dropbox with R

I like to use dropbox for online storage and syncing of R code and data that I am using at home and at work. Storing the code in the cloud means I always have access wherever I am, and that I don’t have to remember to bring my USB flashdrive to and from work.

My work computer (Windows XP) and my home computer (Ubuntu Linux) store their dropbox folders in different locations, meaning that calls to the R function setwd() will work on one of my computers, but not the other.

This chunk of R code checks which operating system R is being run under, and sets the working directory appropriately. I’m sure there are more elegant ways to fix this problem, but this approach works for me.

if(Sys.info()[1]=="Linux") {setwd("/home/michael/Dropbox")} else
                           {setwd("D:/Dropbox/My Dropbox")}