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:
- explain why R is or is not like a Swiss knife;
- categorize R objects into data vs. functions;
- distinguish between different shapes (e.g., scalars, vectors, rectangles) and types (e.g., numeric, character, logical) of data;
- create and change R objects (by assignment);
- apply arithmetic functions to numeric objects;
- create and modify vectors and rectangular tables of data;
- select elements from vectors and rectangular tables of data (by indexing);
- 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:
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.