The following are the activity solutions for this chapter.
Chapter 3: Data Management
Activity: Creating and Manipulating Factor Variables
Use the following code to load the datasets library:
library(datasets)
Use the following code to load the diamonds dataset:
data("diamonds")
The function str() can be used to examine the diamonds dataset as follows:
str(diamonds)
We understand that there are three factors of ordered type as we examine the diamonds dataset. To identify the class of those factors, we can use the function class() as follows:
class(diamonds$cut)
class(diamonds$color)
class(diamonds$clarity)
The following code can be used to load the midwest dataset:
data("midwest")
The str() function can be...