Week 3 – Working with data in R – Shuffle Q/A 1

13. You are working with the ToothGrowth dataset. You want to use the skim_without_charts() function to get a comprehensive view of the dataset. Write the code chunk that will give you this view.

What is the average value of the len column?

  • 18.8
  • 13.1
  • 4.2
  • 7.65

14. A data analyst is working with a data frame named cars.The analyst notices that all the column names in the data frame are capitalized. What code chunk lets the analyst change all the column names to lowercase?

  • rename_with(tolower, cars)
  • rename_with(cars, toupper)
  • rename_with(toupper, cars)
  • rename_with(cars, tolower)

15. A data analyst is working with the penguins dataset and wants to sort the penguins by body_mass_g from least to greatest. When they run the following code the penguin body mass data is not displayed in the correct order.

penguins %>% arrange(body_mass_g)

head(penguins)

What can the data analyst do to fix their code?

  • Save the results of arrange() to a variable that gets passed to head()
  • Add a minus sign in front of body_mass_g to reverse the order
  • Correct the capitalization of arrange() to Arrange()
  • Use the print() function instead of the head() function

16. You are working with the penguins dataset. You want to use the summarize() and mean() functions to find the mean value for the variable body_mass_g. You write the following code:

penguins %>%

drop_na() %>%

group_by(species) %>%

Add the code chunk that lets you find the mean value for the variable body_mass_g.

What is the mean body mass in g for the Adelie species?

  • 3733.088
  • 5092.437
  • 3706.164
  • 4207.433

17. A data analyst is working with a data frame called zoo_records. They want to create a new column named is_large_animal that signifies if an animal has a weight of more than 199 kilograms. What code chunk lets the analyst create the is_large_animal column?

  • zoo_records %>% mutate(is_large_animal = weight > 199)
  • zoo_records %>% mutate(weight > 199 = is_large_animal)
  • zoo_records %>% mutate(is_large_animal == weight > 199)
  • zoo_records %>% mutate(weight > 199 <- is_large_animal)

18. A data analyst is working with a data frame named users. It has separate columns for first name (first_name) and last name (last_name). The analyst wants to combine the two columns into a single column called full_name, with the first name and last name separated by a space. What code chunk lets the analyst create the full_namecolumn?

  • unite(users, first_name, last_name, “full_name”, sep = ” “)
  • unite(users, “full_name”, first_name, last_name, sep = ” “)
  • merge(users, “full_name”, first_name, last_name, sep = ” “)
  • unite(users, “full_name”, first_name, last_name, sep = “, “)

19. A data analyst is using statistical measures to get a better understanding of their data. What function can they use to determine how strongly related are two of the variables?

  • mean()
  • bias()
  • sd()
  • cor()

20. A data analyst wants to find out how much the predicted outcome and the actual outcome of their data model differ. What function can they use to quickly measure this?

  • mean()
  • bias()
  • cor()
  • sd()

21. A data analyst creates a data frame with data that has more than 50,000 observations in it. When they print their data frame, it slows down their console. To avoid this, they decide to switch to a tibble. Why would a tibble be more useful in this situation?

  • Tibbles won’t overload the console because they automatically only print the first 10 rows of data and as many variables as will fit on the screen
  • Tibbles will automatically change the names of variables to make them shorter and easier to read
  • Tibbles only include a limited number of data items
  • Tibbles will automatically create row names to make the data easier to read

22. A data analyst wants to learn more about a specific data frame. Which function will allow them to review the data types of each column in the data frame?

  • package()
  • colnames()
  • library()
  • str()

Shuffle Q/A 2

23. You have a data frame named employees with a column named Last_NAME. What will the name of the employees column be in the results of the function rename_with(employees, tolower)?

  • last_name
  • last_nAME
  • lAST_nAME
  • Last_NAME

24. You are working with the penguins dataset. You want to use the summarize() and min() functions to find the minimum value for the variable bill_depth_mm. You write the following code:

penguins %>%

drop_na() %>%

group_by(species) %>%

Add the code chunk that lets you find the minimum value for the variable bill_depth_mm.

What is the minimum bill depth in mm for the Chinstrap species?

  • 16.4
  • 13.1
  • 15.5
  • 12.4

Devendra Kumar

Project Management Apprentice at Google

Leave a Reply