1.7 Summary

ds4psy: (1) R basics

This chapter provided a very brief introduction to R (R Core Team, 2019). We first distinguished between data and functions and between different shapes and types of data. We then showed how to define objects in R and illustrated some functions to check, compare, or compute other objects from them.

After working through this chapter, you are able to:

  1. explain why R is or is not like a Swiss knife;
  2. categorize R objects into data vs. functions;
  3. distinguish between different shapes (e.g., scalars, vectors, rectangles) and types (e.g., numeric, character, logical) of data;
  4. create and change R objects (by assignment);
  5. apply arithmetic functions to numeric objects;
  6. create and modify vectors and rectangular tables of data;
  7. select elements from vectors and rectangular tables of data (by indexing);
  8. recognize and interpret basic if-then statements and for-loops.

Of course, the mystery and scope of R extends far beyond this modest introduction. At this point, it may be a good idea to take a look at the R Studio Cheat Sheet on Base R (contributed by Mhairi McNeill) to check which concepts and commands you are now familiar with and which others you may still discover in the future:

Base R summary from [R Studio Cheat Sheets](https://www.rstudio.com/resources/cheatsheets/).

Figure 1.2: Base R summary from R Studio Cheat Sheets.

The following chapters will explore and use R from a tidyverse (Wickham, 2017) perspective. But before we continue, let’s test our knowledge and skills by completing the following exercises.

References

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

Wickham, H. (2017). tidyverse: Easily install and load the ’tidyverse’. Retrieved from https://CRAN.R-project.org/package=tidyverse