从列表

时间:2016-01-18 02:59:47

标签: r list

我正在尝试从列表中干净地提取矢量。

下面的代码提供了我想要的数据。但它返回一个列表而不是一个向量。

lst_demo <- list(a = c("a1", "a2", "a3"), b = c("b1", "b2"), 
                                                    c = "c1")
filter_code <- "b"
result <- lst_demo[names(lst_demo) == filter_code]
# result produces what I expect: "b1" , "b2"
result
# but I want the data type to be a vector rather than a list
class(result)

我知道我可以使用as.character投射到矢量,但我正在寻找更清晰的解决方案。

1 个答案:

答案 0 :(得分:1)

因为它尚未作为答案添加(但@thelatemail已将其称为评论)

Error occurred when installing package 'matplolib'
Error: Python packaging tool 'pip' not found

Executed command :
pip install matplotlib

Try to run this command from the system terminal. Make sure that you use the
correct version of 'pip' installed for your Python interpreter located at
'/usr/bin/python3.5'.

Error: Python packaging tool 'pip' not found

可能就是你所追求的。