This is a basic introduction to programming in R. While there are many courses out there, few take you through the very first steps leading up to writing your first line of code, or WHY you would want to write code at all. This course is designed for people who have never programmed before, or who have never used R before. It will take you through the very first steps of programming, and prepare you for more extensive introductory courses. By the end of this course, you should be able to load data, combine datasets, and produce plots.
There are 8 parts, with various tasks to check your understanding, then a final task. If you've used a programming language before, then you can probably complete this course in a few hours. If you're new to programming, you might need about 8 hours to complete. If you've used R before, you could skip to the final task. If you can complete this, then you already know what this tutorial has to offer.
During this tutorial, you will run into errors. This is FINE. It does not mean you are doing something wrong or dangerous, or that you are a bad programmer. You will not lose any files on your computer. Errors just mean that the stupid computer can't understand what you want to do. Remain calm. If you get stuck, you can see the answers to task questions here.
Before you start, take a look at this video on the benefits of learning to program in R for research:
If this is your first experience of programming, code can seem like a wall of impenetrable hieroglyphs. Don't panic! After learning a few basics, you'll see that each row of code is doing one part of a larger taks, and by the end of this tutorial you'll be able to understand what each line of code is trying to do.
Here's a demo of how I use R. I'm not expecting you to understand the code here, but it'll give you an idea of the way that RStudio can be used to do research. The aim is to create a script that takes some anthropological data on roof shape, plots it on a phylogeny and calculates some basic statistics. The point of using a script is that it keeps track of all the decisions we made, so if we want to change things or add data later, it's easy to re-create the plots and stats. You'll also see me stumbling into errors and looking up the help files to fix them. This is all a normal part of programming.
If you're a linguist, I made a similar video but with a linguistic question here.
Before starting, you might want to download this cheat sheet, which summarises the functions you'll learn.
Now you're ready to start on the introduction materials:
You are now ready to learn more about R. You could try: