本文介绍了将列表转换为矢量的更好方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个命名值列表:
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)
这篇关于将列表转换为矢量的更好方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!