Home > database >  Extract two different vectors from set in R
Extract two different vectors from set in R

Time:05-20

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

CodePudding user response:

Using names

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