5 回答
慕沐林林
TA贡献2016条经验 获得超9个赞
是一逻辑值,决定索引向量是否也要返回。注意只对某些情况有效。查到的参数说明如下:
index.return logical indicating if the ordering index vector should be returned as well; this is only available for a few cases, the default na.last = NA and full sorting of non-factors.
慕村9548890
TA贡献1884条经验 获得超4个赞
1、sort()函数描述:对给定区间所有元素进行排序。sort()函数语法:sort(begin,end),表示一个范围。2、sort()函数举例:
| 123456789 | #include <algorithm>#include <iostream>using namespace std;main(){int a[11]={2,4,8,5,7,1,10,6,9,3};//a的长度=待排数据个数+1sort(a,a+10);//对[a,a+10)排序for(int i=0;i<10;++i) cout<<a[i]<<endl;} |
缥缈止盈
TA贡献2041条经验 获得超4个赞
排序(sort)
语法:
void sort();
void sort( Comp compfunction );
sort()函数为链表排序,默认是升序。如果指定compfunction的话,就采用指定函数来判定两个元素的大小
尚方宝剑之说
TA贡献1788条经验 获得超4个赞
例如
| 12 | substr("abcdef", 2, 4) # 提取第2到第4位置的元素[1] "bcd" |
获得位置 应该用 grep( )
| 1234567 | a<-LETTERS[1:8]#输出的#> a#[1] "A" "B" "C" "D" "E" "F" "G" "H" grep("D",a,value=F)# 结果 [1] 4 D在a 中的第四个 |
# 缺点是这函数一次只能提取一个
#针对这个问题可以设计一个循环 函数 一次可以提取index里面的多个
| 123456789101112 | f<-function(index,x){a<-c()for (i in index){ a[i]<-grep(i,x,value=F)}return(a)} #测试:x<-aindex<- c("A","D","H")f(index,x) |
结果截图:
- 5 回答
- 0 关注
- 1610 浏览
添加回答
举报
0/150
提交
取消

