IniziaInizia gratis

Subsetting list elements

You can also subset within list elements using bracket notation like this: ListName$ElementName[VectorNumber]. If a list element is a data frame, you can pull out a column like this: ListName$ElementName$ColumnName or ListName[[1]][,1].

In this exercise, you’ll examine the wesanderson and sw_films datasets from the repurrrsive package.

wesanderson contains color palettes for each of Wes Anderson's movies. These colors are recorded in hexadecimal, that is, a # followed by six digits that indicate a particular color. Here, you will be using two ways of pulling out a particular color hexadecimal.

sw_films contains information about the films in the Star Wars franchise, such as title, director, producer, etc. You'll use subsetting to explore this dataset.

Questo esercizio fa parte del corso

Foundations of Functional Programming with purrr

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Third element of the first wesanderson vector
___[[___]][___]

# Fourth element of the GrandBudapest wesanderson vector
____$___[___]
Modifica ed esegui il codice