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