How to Extract Several List Elements in R Programming (Example Code)
This post explains how to subset multiple list elements in R programming.
Example Data
example_list <- list(5, # Constructing an example list c(8, 4, 1), LETTERS[2:5], 77777) example_list # Structure of the list # [[1]] # [1] 5 # # [[2]] # [1] 8 4 1 # # [[3]] # [1] "B" "C" "D" "E" # # [[4]] # [1] 77777
Example: Using Index Positions to Subset List
example_list[c(2, 4)] # Extracting only some list elements # [[1]] # [1] 8 4 1 # # [[2]] # [1] 77777