This page covers what you need to get started with R from a programming perspective. The goal is for this to be an approachable but specific way to get your bearings!

Most of this is core information needed to use and understand R at the level psychologists use it. Boxes with 📎  have extra information and resources to get even better.

<aside> 📎 More resources

If you’re reading a pdf right now and would prefer a webpage (with embedded videos and such), you can access that here.

For a more comprehensive overview of base R (not R studio or any packages), see:

An Introduction to R

Alternatively: https://www.w3schools.com/r/default.asp (This website has great free tutorials of a lot of programming languages and paradigms in general!)

Or: https://www.edx.org/learn/r-programming/harvard-university-data-science-r-basics (Free Edx course on data science in R)

</aside>

Table of Contents

R and R Studio

***R*** is a programming language. That means you write programs using a particular style (syntax) that will be saved as R files and evaluated by the R software. So first thing’s first, this R software needs to be downloaded on your computer.

<aside> 📎 Programming languages are just systems for writing computer programs. It’s not much different than the idea of “software,” maybe just a little more specific. Think about how you can design a slide show in Microsoft Powerpoint or Apple Keynote. Different styles and advantages, same product.

Programming languages often have different syntax, or conventions for writing out the same process. For example, you might be able to write “1 + 1” in one language but have to write “sum(1, 1)” in another.

Different programming languages offer different advantages, depending on what they were designed for. One might run faster but be harder to write/read, and another might be really easy to interpret at the expense of performance.

</aside>

More specifically, R is a programming language designed for data science, meaning it’s good for cleaning, analyzing, and visualizing datasets.

R Studio is a a fancy application designed independently for developing R programs (these are often called IDEs or Integrated Development Environments). It is not strictly necessary for coding in R, but it’s pretty much standard and would be insane not to use.

Once you’ve downloaded both R and R Studio you should have 2 applications. It’s best to make sure these are both in your Applications folder so there’s no problem with the two “talking” to each other.

Screenshot 2023-06-22 at 3.56.54 PM.png

<aside> 📎 Programming languages, text editors, and IDE’s These concepts are all very related but distinct. For any given programming language (ex. python, R, html), you need a place to develop those programs. You can go simple and just do that in a text editor (ex. Atom and Sublime). However, these days programmers usually use applications that have a lot of tools to make developing easier, which are called IDEs (R Studio, VS Code, IntelliJ). Some IDEs are only geared toward one programming language, whereas others can accommodate a ton.

</aside>

So now you have your coding language and your coding environment. This can be thought of as the kinds of files you are writing vs where you are writing them. If things are breaking / out of date / incompatible, you might have to check both your R version and your R Studio version.

Once you open R Studio for the first time, it should automatically load R (which it finds on your computer), and you should see this. If you do, we’re ready to go!

Screenshot 2023-06-22 at 4.01.37 PM.png

Before moving on, you should learn a bit about how R Studio works. Watch this video for an overview of the R Studio environment: