Category: R
-
An Introduction to Reproducible Research in R and R Studio.
**Updated 4th April 2016** I have recently volunteered to give a few talks on how straightforward it us to conduct research in a reproducible manner using R and the R Studio environment. This talk covers the following topics: What is reproducible research, and why should we do it? Four simple rules for reproducibility. A step by step…
-
Make R beep when R Markdown finishes – or when it fails.
I often run time-consuming scripts, so I’m a big fan of ‘s Rasmus Bååth beepr package in R. I often put beep() at the end of my .R files to let me know when analyses are done. However, when using R Markdown and knitr in RStudio, this is a poor solution when there is an…
-
Step by Step: A Stylised Pedigree using reshape and ggplot2
During a minor bout of procrastination, I produced a stylised pedigree using Hadley Wickham's amazing reshape and ggplot2 packages in R. Not being particularly artistically minded, I was quite chuffed with the end product: Ancestors & descendants from single Soay sheep "Snowball" on St Kilda. Made in R using reshape & ggplot2. #rstats pic.twitter.com/nOhkkpYN7G —…
-
Creating a large scale map using ggplot2: a step by step guide.
Updated version of previous post!
-
Base Graphics in R: A Detailed Idiot’s Guide
One of the most powerful functions of R is its ability to produce a wide range of graphics to quickly and easily visualise data. Plots can be replicated, modified and even publishable with just a handful of commands. Making the leap from chiefly graphical programmes, such as Excel and Sigmaplot may seem tricky. However, with…
-
A quick and easy function to plot lm() results with ggplot2 in R
Updated Apr 2015: Sometimes it's nice to quickly visualise the data that went into a simple linear regression, especially when you are performing lots of tests at once. Here is a quick and dirty solution with ggplot2 to create the following plot: Let's try it out using the iris dataset in R: data(iris) head(iris) ##…
-
Find and Replace in R, Part 1:
recodein the librarycarBackground Recoding a variable in R has never seemed like a straightforward task to me. In the next few entries, I will present the do’s and dont’s of different find/replace (recoding) solutions in R. Today: car::recode. 1. Recoding vectors: Load the library car, and create a vector of random integers from 1 to 4: library(car)…
-
Creating a large scale map using ggplot2: a step by step guide.
* UPDATED 2nd SEPTEMBER 2013 * Whenever I have needed a map in a presentation, I have always slipped in a cheeky screenshot from Google and prayed that the copyright police won’t burst into the door and arrest me (talks are stressful enough). However, I was determined to change this, and after extensive trawling of…