setwd("~/Desktop/R Examples")
#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.
c_album <- c("SOS Deluxe", "Freudian", "eternal sunshine", "4 ONLY", "130 Mood: TRBL")
Q2 Create another vector of the musicians, writers, or directors
corresponding to the works you specified in (1).
c_musician <- c("SZA", "Daniel Caesar", "Ariana Grande", "LeeHi", "DEAN")
Q3 Create another vector corresponding to the years those works were
produced.
c_year <- c("2024", "2017", "2024", "2021", "2016")
Q4 Combine the vectors into a dataframe, with appropriate column
labels.
dataframe_MUSIC <- data.frame(Album = c_album, Musician = c_musician, Year = c_year)
Q5 Call the dataframe to produce it in your output.
dataframe_MUSIC$Album
## [1] "SOS Deluxe" "Freudian" "eternal sunshine" "4 ONLY"
## [5] "130 Mood: TRBL"
dataframe_MUSIC$Musician
## [1] "SZA" "Daniel Caesar" "Ariana Grande" "LeeHi"
## [5] "DEAN"
dataframe_MUSIC$Year
## [1] "2024" "2017" "2024" "2021" "2016"
Q6
dataframe_MUSIC[,3]
## [1] "2024" "2017" "2024" "2021" "2016"
Q7
dataframe_MUSIC[4,]
## Album Musician Year
## 4 4 ONLY LeeHi 2021