为了账号安全,请及时绑定邮箱和手机立即绑定

请问r语言sort函数中index是什么意思?

请问r语言sort函数中index是什么意思?

潇潇雨雨 2019-07-08 10:06:33
r语言sort函数中index是什么意思
查看完整描述

4 回答

?
慕雪6442864

TA贡献1812条经验 获得超5个赞

是一逻辑值,决定索引向量是否也要返回。注意只对某些情况有效。查到的参数说明如下:

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.

查看完整回答
反对 回复 2019-07-13
?
沧海一幻觉

TA贡献1824条经验 获得超5个赞

1、sort()函数描述:对给定区间所有元素进行排序。sort()函数语法:sort(begin,end),表示一个范围。2、sort()函数举例:

1

2

3

4

5

6

7

8

9

#include <algorithm>

#include <iostream>

using namespace std;

main()

{

int a[11]={2,4,8,5,7,1,10,6,9,3};//a的长度=待排数据个数+1

sort(a,a+10);//对[a,a+10)排序

for(int i=0;i<10;++i) cout<<a[i]<<endl;

}

 


查看完整回答
反对 回复 2019-07-13
?
偶然的你

TA贡献1841条经验 获得超3个赞

排序(sort)
语法:
void sort();
void sort( Comp compfunction );

sort()函数为链表排序,默认是升序。如果指定compfunction的话,就采用指定函数来判定两个元素的大小

查看完整回答
反对 回复 2019-07-13
?
海绵宝宝撒

TA贡献1809条经验 获得超8个赞

例如:有个 int a[1000] 的数组要排序。而比较函数你已经写好了名字是 comp,则这样写:

1qsort(a,1000,sizeof(int),comp);

  比较函数 comp 如下:

1234int comp ( const void *a, const void *b ){        return * ( int * ) a - * ( int * ) b;}

 详细的可以查一下关于 qsort 的说明。


查看完整回答
反对 回复 2019-07-13
  • 4 回答
  • 0 关注
  • 927 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信