R tip: Access nested list items with purrr

R tip: Access nested list items with purrr

Assessment

Interactive Video

Architecture, Social Studies, Geography, Science

University

Practice Problem

Hard

Created by

Wayground Content

FREE Resource

This video tutorial explores handling nested lists in R using the purrr package. It demonstrates geocoding addresses with the R Geocode IO package, resulting in latitude and longitude data nested in list columns. The tutorial explains how to extract and manipulate data from these list columns using purrr's modify_depth function, showcasing elegant solutions for data extraction and modification. The video concludes with converting list data into vectors and integrating them into the original data frame.

Read more

7 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is one of the main challenges when working with nested lists in R?

They are always empty.

They require a lot of memory.

They can have inconsistent structures.

They are not supported in R.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which package is used in the example to geocode addresses?

R Geocode IO

tidyverse

ggplot2

dplyr

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of the modify_depth function in the purrr package?

To sort data frames.

To modify list columns at a specified depth.

To create new data frames.

To delete list columns.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you change all values in a data frame column to lowercase using purrr?

Use the toupper function.

Use a for loop.

Use modify_depth with a formula.

Use the tolower function directly.

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of using bracket one on a vector in R?

It returns the first element.

It duplicates the vector.

It deletes the vector.

It returns the last element.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you convert a list to a vector in R using purrr?

By using the as_vector function.

By using the as_list function.

By using the as_dataframe function.

By using the as_matrix function.

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What function is used to add vectors to the original data frame?

arrange

filter

select

mutate