将命名列表转换为仅包含值的向量 [英] Convert named list to vector with values only
本文介绍了将命名列表转换为仅包含值的向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个命名值列表:
myList <- list('A' = 1, 'B' = 2, 'C' = 3)
我想要一个值为 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)
是否有类似于 myList$Values
的东西来剥离名称并将其作为向量返回?
Is there something akin to myList$Values
to strip the names and return it as a vector?
推荐答案
使用 unlist
和 use.names = FALSE
参数.
unlist(myList, use.names=FALSE)
这篇关于将命名列表转换为仅包含值的向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文