2.6 Lists - JulTob/R GitHub Wiki
A generic multi valued structure:
my_list <- list(your_comp1, your_comp2)
my_list <- list(name1 = your_comp1,
name2 = your_comp2)
#----------
my_list <- list(your_comp1, your_comp2)
names(my_list) <- c("name1", "name2")
#---------
Your list will often be built out of numerous elements and components. Therefore, getting a single element, multiple elements, or a component out of it is not always straightforward.
One way to select a component is using the numbered position of that component. For example, to "grab" the first component of shining_list you type
shining_list[1](/JulTob/R/wiki/1)
A quick way to check this out is typing it in the console. Important to remember: to select elements from vectors, you use single square brackets: [ ]. Don't mix them up!
You can also refer to the names of the components, with or with the $ sign. Both will select the data frame representing the reviews:
shining_list["reviews"](/JulTob/R/wiki/"reviews")
shining_list$reviews
Besides selecting components, you often need to select specific elements out of these components. For example, with shining_list2[1] you select from the second component, actors (shining_list2), the first element ([1]). When you type this in the console, you will see the answer is Jack Nicholson.