Is there a shorter way to return the values by key in the order, which is given by elements of key?
vars<-c("a"=1,"b"=2)
key<-c("b","a")
ret<-c()
for(k in key)
ret<-c(ret,vars[names(vars) %in% k])
ret
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…