#set up working directory (1pt)
getwd()
## [1] "/Users/owner/Downloads"
setwd("/Users/owner/Desktop")
#use second level header for each question (1pt)
#submit both knitted file and Rmd. (1pt)
Q1 Create a vector of 5 of your favorite albums, books, or
films.
These are the book titles of my 5 favorite books.
c_book <- c("A Little Life", "The Kite Runner", "Dracula", "The Boy, the Mole, the Fox and the Horse", "Before the Coffee Gets Cold")
Q2 Create another vector of the musicians, writers, or directors
corresponding to the works you specified in (1).
These are the writers corredpsonding to the books I specified in
Q1.
c_writer <- c("Hanya Yanagihara", "Khaled Hosseini", "Bram Stoker", "Charlie Mackesy", "Toshikazu Kawaguchi")
Q3 Create another vector corresponding to the years those works were
produced.
These are the corresponding publication years for the books I
specified.
c_year <- c(2015,2003, 1897, 2022, 2015)
Q4 Combine the vectors into a dataframe, with appropriate column
labels.
This is me creating a data frame, with labels for the writers, book
titles, and publication years.
dataframe_reading <- data.frame(Writer=c_writer, Book=c_book, Year=c_year)
Q5 Call the dataframe to produce it in your output.
The dataframe is based on the books, so I called it reading.
dataframe_reading
## Writer Book Year
## 1 Hanya Yanagihara A Little Life 2015
## 2 Khaled Hosseini The Kite Runner 2003
## 3 Bram Stoker Dracula 1897
## 4 Charlie Mackesy The Boy, the Mole, the Fox and the Horse 2022
## 5 Toshikazu Kawaguchi Before the Coffee Gets Cold 2015
Q6
This is me calling only the “year” column to produce it in my
output.
dataframe_reading$Year
## [1] 2015 2003 1897 2022 2015
Q7
This is me calling just the fourth row to produce it in my
output.
dataframe_reading[4,]
## Writer Book Year
## 4 Charlie Mackesy The Boy, the Mole, the Fox and the Horse 2022