Chapter 1 Basic R concepts and commands

ds4psy: (1) R basics

This chapter lays the foundations for the rest of the book by providing essential background knowledge: First, some terminology on R components, basic distinctions about data shapes and types — that apply not only to R, but also other programming languages — and then some fundamental concepts and commands of base R (R Core Team, 2019).

R basics _prepare_ us for the other parts of this course ---<br> and is an important topic for our future adventures in data science.

Figure 1.1: R basics prepare us for the other parts of this course —
and is an important topic for our future adventures in data science.

To learn R, we first need to install some software and introduce some basic terminology for talking about data and code. As this is not an R textbook, we introduce these concepts and commands only briefly and in a playful fashion — by providing examples, interpreting code outputs, and completing a few exercises. Strictly speaking, knowing some R is not a necessary precondition for reading and learning data science with the r4ds textbook (Wickham & Grolemund, 2017). However, having encountered certain terms and various base R commands before is helpful — partly to appreciate later how various tidyverse commands let you solve similar problems in simpler and more transparent ways. Thus, please work through these examples, aim to understand them, and then try to solve the corresponding exercises (in Section 1.8). But if anything seems cryptic or obscure at this point, do not despair or panic. Instead, make a mental note of the task that remained unclear and trust that things will clear up in subsequent chapters. It’s quite likely that you will later learn to solve similar tasks in different ways.

References

R Core Team. (2019). R: A language and environment for statistical computing. Retrieved from https://www.R-project.org

Wickham, H., & Grolemund, G. (2017). R for data science: Import, tidy, transform, visualize, and model data. Retrieved from http://r4ds.had.co.nz