所以,如果我有:
> g<-c(1,5,2,4,6)
> names(g)<-c("josh","daniel","john", "luke", "bill")
> g
josh daniel john luke bill
1 5 2 4 6
>
> g[c("john", "daniel", "bill")]
john daniel bill
2 5 6
Run Code Online (Sandbox Code Playgroud)
是否有可能返回最初用g命令的值,即(daniel then john then bill)没有使用排序函数?
谢谢!-Josh
hat*_*rix 11
%in% 会为你做这件事:
> g[names(g) %in% c("john", "daniel", "bill")]
daniel john bill
5 2 6
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
77 次 |
| 最近记录: |