Home
11.
What are the names of the three built-in classes of numbers?

numeric, integer, and complex

12.
What function would you call to find out the number of levels of a factor?

nlevels

13.
How might you convert the string “6.283185” to a number?

as.numeric("6.283185")

14.
Name at least three functions for inspecting the contents of a variable.
Any three of summary, head, str, unclass, attributes, or View. Bonus points if you’ve discovered tail, the counterpart to head that prints the last few rows.

15.
How would you remove all the variables in the user workspace?

rm(list = ls())

16.
How would you create a vector containing the values 0, 0.25, 0.5, 0.75, and 1?

seq.int(0, 1, 0.25)

17.
Describe two ways of naming elements in a vector.

Either by using name = value pairs when the vector is created, or by calling the names function afterward.

18.
What are the four types of index for a vector?

Positive integers for locations to retrieve, negative integers for locations to avoid, logical values, or names of elements.

19.
What is the length of a 3-by-4-by-5 array?

3 * 4 * 5 = 60

20.
Which operator would you use to perform an inner product on two matrices?

%*%