Extract two different vectors from set in R

Viewed 24

How can I extract the set of (a) and set of (b) as shown in the image to two different vectors, the first vector for (a) values and the second for (b) values

enter image description here

1 Answers

Using names

> tmp=c("a"=1,"b"=2,"a"=3,"b"=5)
> tmp[names(tmp)=="a"]
a a 
1 3
Related