2.6 Exercises

i2ds: Exercises

The following exercises allow to verify your understanding on basic R concepts and commands:

2.6.1 The ER of R

When discussing the fit between tools and tasks in Chapter 1, we encountered the notion of ecological rationality (ER, in Section 1.2.6). Now that we have learned some basic R concepts and commands, we can ask:

  • Where would R be located in Figure 1.7?

  • Where could we place an individual R function?

  • How does the arrangement change when distinguishing between R (the language), RStudio (the IDE), or some R package?

Note: Try answering these questions in a few sentences, rather than optimizing your answers. Thinking too long about these issues can make us quite dizzy.

The following exercises can be solved by using vectors as the only R data structure:

2.6.2 Data types and forms

Please answer the following questions in a few sentences:

  1. Describe the similarities and differences between scalars and vectors in R.

  2. What are the main data types in R? Which function(s) allow checking or verifying them for a given data object?

  3. Describe the difference between logical and numeric indexing (of a vector) in your own words.

2.6.3 Exploring a function

2.6.4 Cumulative savings

2.6.5 Vector arithmetic

2.6.6 Cryptic arithmetic

This concludes our exercises on basic R concepts and commands.