top of page
  • Writer's pictureKiirsti Owen

The 25 days of chRistmas: an R advent calendaR

Updated: Dec 19, 2019

Thank you for your interest in this advent calendar and learning R! R is a powerful tool for data analysis and visualization. At first, it can be really overwhelming, but after you pick up the basics, it becomes much less terrifying and a lot more fun!

The original purpose of this advent calendar was to teach my partner, who had expressed an interest in learning R, the basics in an easy-to-use, fun way. This tutorial was designed for people with zero experience or familiarity with R. I hope that by Christmas, you will have learned enough to feel comfortable doing basic things with your own data, working through online tutorials, or searching the internet for more you can learn in R.

Many people have said they would be willing to pay for this advent calendar. While I appreciate these offers, I have chosen to keep it free, and therefore, accessible to everyone. However, if you recognize the time and energy put into this and wish to contribute something, I would ask that you instead make a small contribution to the non-profit I am involved with called WildResearch. We are a non-profit based in Vancouver, BC and our mission is to build, train, and educate a community that contributes to conservation science. One of the workshops we’re hoping to run in the future is an in-class R learning session, so by contributing you can help promote future training opportunities for scientists, students, and volunteers!

Finally, I relied on many resources to help build this. I tried to add links to some that I find particularly helpful. Thank you to Rick Simpson (@ColSciSimpson) who introduced me to the basics in R and gave me some input on what to include, to Christine Kuntzmann (@ChristineKmann) who shared a helpful R tutorial that I used for ideas, and to Roland Eveleens (@roland _eveleens) who went through this calendar before I shared it to make sure everything made sense. And, of course, a big thank you to my partner, Colin, who inspired me to make this calendar (that he doesn't even know about yet!).

Download the files here. Includes 25 text files (Days 1 to 25) and two CSV files (datasets to work with). Be sure to download the entire folder, or save them to a folder with the same name on your desktop ("advent_calendaR").

Instructions: open one file a day starting with Day 1 on December 1st. You will need to work through these in order (Day 1 to Day 25). If you miss a day or start late, work through the ones you missed before moving on.

If you work through this tutorial, I would really appreciate if you leave comments or suggestions below (or on Twitter!).

Merry Christmas and happy coding!


If you find errors or areas that need more clarity, please let me know and I will keep an updated list here. If you're seeking more information about a particular topic, I suggest searching online, the R community is amazingly helpful! Here's a good place to start.

  • I noticed that some quotation marks changed when I copied and pasted text into the R source window. If you’re running code with “ “s and getting error messages, try deleting just the “ “ and retyping them. I think the text file replaces straight quotes with the “smart” quotes (i.e. curved quotation marks). R does not recognize the “smart” quotes.

  • If you are getting error messages that say something doesn’t exist, you likely just need to rerun your code from earlier. This might include re-running your setwd(), read.csv(), library() for all packages, and then your vectors (anything with <- pointing to it).

  • One of the most common errors is missing or extra brackets, quotation marks, operators, or spelling errors. If you’re getting errors, double-check that you’re not missing something or have accidentally added something.

  • I suggest putting the advent_calendaR on the Desktop and setting it as your working directory for the purpose of this tutorial. If you move it at all during the month, you will need to reset your working directory. More information on working directories.

  • Day 14: I moved a later lesson up a few days, but forgot to mention that you will need to load in the new dataset (I mention it on Day 16). Before working through Day 14, load the new dataset: tree.dat<-read.csv("xmas.trees.csv")

  • Day 14: there is a " out of place. Make sure that the " follows .csv (like above).

  • Day 16: For the first boxplot, replace ~ with , otherwise the boxplot will look very odd! So it should be boxplot(pines$height, spruces$height)

If none of these suggestions help, try copy-pasting your error message and searching it online. If people contact me with a common error, I will add it to this list. Also, be sure to check out Jason Winget's (@iplusfour) helpful youtube videos for each day of the calendaR.

45,846 views1 comment

1 Comment

Marc Goff
Marc Goff
Oct 15, 2021

Hello! I just wanted to say how much help this is! I did the whole thing in an afternoon, after having been intimidated away from R by my codeacademy experience! This is the best! You should publish it! It's a wonderful resource. Thank you!!!!

bottom of page