亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請問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 關注
  • 1078 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號