Question 1
- Create an object called pitt_wvu, store the number 107 in it, and
then print it.
- Create an object called backyard_brawl, store “Pitt”, “vs.” and
“WVU” in it, and then print it.
- Create an object called sweet_caroline, store the phrase “LET’S GO
PITT!” in it, and then print it.
pitt_wvu <- 107
print(pitt_wvu)
## [1] 107
backyard_brawl <- c("Pitt", "vs.", "WVU")
print(backyard_brawl)
## [1] "Pitt" "vs." "WVU"
sweet_caroline <- "LET'S GO PITT!"
print(sweet_caroline)
## [1] "LET'S GO PITT!"
Question 2
Use the function read.csv() to read the CSV file harry_potter.csv and
use the assignment operator <- to store the data in an object.
harry_potter <- read.csv("harry_potter.csv")
Question 3
- Use the function head() to view the first few observations of the
dataset.
- Please substantively interpret the SECOND observation in the
dataset.
head(harry_potter)
## name age house student
## 1 Harry Potter 44 Gryffindor 1
## 2 Hermione Granger 45 Gryffindor 1
## 3 Ron Weasley 44 Gryffindor 1
## 4 Draco Malfoy 44 Slytherin 1
## 5 Minerva McGonagall 99 Gryffindor 0
## 6 Cedric Diggory 47 Hufflepuff 1
The second observation describes Hermione Granger, who is 45 years
old, in Gryffindor, and is a student.
Question 4
- How many observations and variables are in the dataset? Use the
function dim().
- Identify the type of each variable in the dataset.
dim(harry_potter)
## [1] 17 4
There are 17 observations and 4 variables.
The first variable, the name, is non-binary character variable. The
second variable, age, is a non-binary numerical variable. The third
variable, house type, is a non-binary character variable. The fourth
variable, student, is a binary numeric value.