Programming

A gentle introduction to programming using R

Workshop dates: 2018-01-19, 2018-01-24
Author: Jon Pipitone, 2018

Big ideas

Here are the big takeaways I’d like you to leave with:

  • Syntax is critical.
    A missing parenthesis, an extra comma… You can read past these things, but the machine will not. Be vigilant and precise.

  • When in doubt, read the docs. Or stackoverflow.
    Everything you write in a programming language has a precise meaning, and someone has often laboured to spell that out in the help(). If that fails, search stackoverflow.com because you aren’t the first to run into this problem.

  • Programming is a skill. Be patient, expect frustration.
    Exactly like learning a language, programming is a skill you develop with practice, but unlike learning a language, the world of programming changes quickly and constantly, so you will always be learning.

Learning objectives

Most important:

  • RStudio: what an IDE is, and why you would use it
  • Major parts of an RStudio: file editor, console, memory display, inline help
  • How the R console works: the read-eval-print-loop
  • How to get help when learning R?
  • What variables a is, and how to tell what it contains
  • Kinds of data: numbers, strings, vectors, lists, …
  • How to manipulate numbers, strings, vectors, lists
  • Functions: how to call base functions, and functions from libraries
  • Libraries: how to install them, load them, and get help on them

Tasks

This workshop is a Choose Your Own Adventure. Depending on your experience, you may want more or less hand-holding as you learn programming with R, and you may want more or less interactivity.

  • Do DataCamp’s R Tutorial.

    My opinion: This is good if you’re a beginner, like to figure things out on your own, and like doing short, interactive, and independent exercises with instant feedback as you go.

    DataCamp has also given us special access to their full set of online lessons for the next few months, so worth checking out to see if this learning format works for you.

  • Do Software Carpentry’s lesson on Programming with R.

    My opinion: This is good if you’re a beginner, and want explanation of concepts and tasks as you go, and need to see a purpose behind what you’re learning as you do it. These lessons try to give you an overview of the R programming language, so some sections may seem irrelevant if all you want to do is crunch numbers, but it’s all useful stuff.

  • Do Data Carpentry’s lesson R for data anlysis and visualisation

    My opinion: This is good if you’ve have a little programming experience, or find yourself picking stuff up quickly. It is focused on very useful tools for analysis and visualization, and so doesn’t cover some of the general features of R like the Software Carpentry workshop does.

  • Do DataCamp’s lessons Intermediate R or Introduction to the TidyVerse

    My opinion: You’ll need to have some background in R and programming to dig into these lessons.

Resources

  • Rstudio Online Learning

    A great starting place to learn R on your own. This page contains links to online tutorials, guides and software to help you learn R well. Recommend.

  • Good enough practices in scientific computing

    You may not think you are doing “scientific computing” but welcome to the 21st century: you probably are. This paper outlines the basic strategies you should strive towards when you get going.