Exercises 2 - Objects

Files corresponding to Short Course: Introduction to Data Science Using R

Exercises 2 - Objects

2.1 Creating R Objects

  1. The code below creates a vector of three character strings (more on vectors shortly). Use this code and the ‘storage arrow’ to create an object names adj.

c("scary","intelligent","new")

  1. Similarly, create an object called nouns using the storage arrow and code below.

c("bugs", "beings", "houses")

  1. The paste() function is useful for combining character strings. After completing the above parts, run the following:

paste(adj, nouns)


2.2 Investigating Objects

  1. iris is a built-in R object (that means you have it in your environment even if it doesn’t show it). Determine the class and structure (str) of the iris object.

  2. Run the code below to create a quick visual of this dataset. Note that R is determining what to do with the plot() function based on the object given to it!

plot(iris)