How to Convert List to Unnamed Vector in R (Example Code)
This article shows how to convert a list to a vector object in the R programming language.
Example Data
example_list <- list(a = 15, # Constructing example list b = 22, c = 7) example_list # Showing list in RStudio console # $a # [1] 15 # # $b # [1] 22 # # $c # [1] 7 # |
example_list <- list(a = 15, # Constructing example list b = 22, c = 7) example_list # Showing list in RStudio console # $a # [1] 15 # # $b # [1] 22 # # $c # [1] 7 #
Example: Applying unlist Function to Convert List to Vector
unlist(example_list, use.names = FALSE) # [1] 15 22 7 |
unlist(example_list, use.names = FALSE) # [1] 15 22 7
Further Resources & Related Tutorials
Have a look at the following R tutorials. They explain topics such as lists, vectors, and data conversion.