Exercise

List structure

Often when working in R, you'll use data frames or vectors. Another kind of R object is a list. While lists can be complicated, lists are also incredibly powerful. Lists are like Hermione Granger's bag of holding (from Harry Potter); they can hold a wide variety of things. The contents of a list don't have to be the same data type, and as long as you know how it's organized, you can grab out what you need by subsetting.

Both named and unnamed lists can be subset using double square brackets [[ ]] list this: listname[[ index ]]

If a list is named, you can also use $ for subsetting. The syntax list$elementname pulls out the named element from the list. Like any other kind of object in R, you can use the str() to determine the structure of the list.

Instructions

100 XP
  • Load the repurrrsive package.
  • Load the wesanderson dataset.
  • Examine the structure of the first element in wesanderson.
  • Examine the structure of the GrandBudapest element in wesanderson.