dictionary - R fastest way to get values from list as vector -
this question has answer here:
- better way convert list vector? 2 answers
in r, give list
l1 <- list(a = "a", b = "b", c = "c")
and vector
v<- c("a", "c")
how elements list in vector? example
l1[v]
returns list, while need vector as
c("a", "c")
looking fastest one-liner.
you can try this, similar @colonelbeauvel
identical(as.vector(unlist(l1[v])), c("a", "c")) [1] true
Comments
Post a Comment