Convert named list to vector with values only

sharoz picture sharoz · Jun 13, 2013 · Viewed 109k times · Source

I have a list of named values:

myList <- list('A' = 1, 'B' = 2, 'C' = 3)

I want a vector with the value 1:3

I can't figure out how to extract the values without defining a function. Is there a simpler way that I'm unaware of?

library(plyr)
myvector <- laply(myList, function(x) x)

Is there something akin to myList$Values to strip the names and return it as a vector?

Answer

Arun picture Arun · Jun 13, 2013

Use unlist with use.names = FALSE argument.

unlist(myList, use.names=FALSE)