STT 180 Exam 1 Questions and Correct
Answers
Is a dplyr function that chooses rows matching a set of criteria
Ans: filter()
ex. flights %>%
filter(air_time > 60)
Is a dplyr function that chooses rows using indices Ans: slice()
ex. slice(mtcars, 1:3)
Is a function of dplyr that chooses columns by name Ans: select()
ex. mtcars %>%
select(mpg, hp, wt)
Grabs a column as a vector Ans: pull()
ex. mtcars %>%
© 2025 All rights reserved
, 2 | Page
pull(1) or pull(cyl)
rename specific columns Ans: rename()
ex. mtcars %>%
rename(NewName = OldName)
reorder rows in ascending and descending order Ans: arrange()
ex. mtcars %>%
arrange(cyl) ##Ascending
arrange(cyl,mpg) ##Reorders both
arrange(desc(cyl)) ##Descending
adds new variables to the data frame Ans: mutate()
ex. mtcars %>%
mutate(new_variable = mpg/5)
creates a new data frame with new variables Ans: transmute()
© 2025 All rights reserved