Lesson 1 of 14 · 10 min
What Are R and RStudio?
R is a free, open-source programming language built for working with data and statistics. Open-source means its underlying code is public, so anyone can download, use, and improve it at no cost. A programming language is simply a set of typed instructions that a computer follows exactly. You write those instructions as short lines of text, R reads them, and it does the work for you.
Why Biologists Use R
Biologists use R because experiments produce large tables of numbers, and R can summarize, test, and plot them far faster than clicking around a spreadsheet. It is widely used in genomics, ecology, and clinical research, so ready-made tools already exist for tasks like analyzing gene expression. Because R is free, anyone can install it and reproduce your exact analysis.
The RStudio Workspace
R by itself is just the language, while RStudio is a free application that wraps R in a friendly workspace. Its window is split into four panes: the console runs a command the moment you press Enter, and the script editor is where you write and save longer code. The environment pane lists the values you have stored, and the fourth pane holds separate tabs for your plots (the graphs you create) and the files in your project folder, which you switch between by clicking.
R As A Calculator
2 + 2
10 / 4[1] 4
[1] 2.5
The slash means divide, so ten divided by four gives the decimal 2.5. The [1] at the start of each result is just a label meaning the first value on that line, and you can ignore it for now. To reuse a number later, store it in a variable using the assignment operator, typed as a less-than sign followed by a dash, in the form name <- value. Storing a value prints nothing on its own, so in the next example the first line shows no output; typing the variable's name on its own line then displays the stored value, and you can use that name in further calculations.
weight_g <- 24
weight_g
weight_g * 1000[1] 24
[1] 24000
Try it yourself: In the RStudio console, type height_cm <- 170 and press Enter, then on the next line type height_cm / 100 to convert your height to meters. Check the environment pane and confirm height_cm now appears there holding the value 170.