5 回答

TA貢獻(xiàn)2016條經(jīng)驗(yàn) 獲得超9個(gè)贊
是一邏輯值,決定索引向量是否也要返回。注意只對(duì)某些情況有效。查到的參數(shù)說明如下:
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.

TA貢獻(xiàn)1884條經(jīng)驗(yàn) 獲得超4個(gè)贊
1、sort()函數(shù)描述:對(duì)給定區(qū)間所有元素進(jìn)行排序。sort()函數(shù)語法:sort(begin,end),表示一個(gè)范圍。2、sort()函數(shù)舉例:
123456789 | #include <algorithm> #include <iostream> using namespace std; main() { int a[11]={2,4,8,5,7,1,10,6,9,3}; //a的長度=待排數(shù)據(jù)個(gè)數(shù)+1 sort(a,a+10); //對(duì)[a,a+10)排序 for ( int i=0;i<10;++i) cout<<a[i]<<endl; } |

TA貢獻(xiàn)2041條經(jīng)驗(yàn) 獲得超4個(gè)贊
排序(sort)
語法:
void sort();
void sort( Comp compfunction );
sort()函數(shù)為鏈表排序,默認(rèn)是升序。如果指定compfunction的話,就采用指定函數(shù)來判定兩個(gè)元素的大小

TA貢獻(xiàn)1735條經(jīng)驗(yàn) 獲得超5個(gè)贊
R里沒有專門的十六進(jìn)制類型吧,你是不是輸入的是表示十六進(jìn)制數(shù)的字符串?。渴堑脑捯扔胹trtoi()轉(zhuǎn)換成R里的整數(shù)類型,再排序。

TA貢獻(xiàn)1788條經(jīng)驗(yàn) 獲得超4個(gè)贊
例如
12 | substr( "abcdef" , 2 , 4 ) # 提取第2到第4位置的元素 [ 1 ] "bcd" |
獲得位置 應(yīng)該用 grep( )
1234567 | a<- LETTERS [ 1 : 8 ] #輸出的 #> a #[1] "A" "B" "C" "D" "E" "F" "G" "H" grep( "D" ,a,value= F ) # 結(jié)果 [1] 4 D在a 中的第四個(gè) |
# 缺點(diǎn)是這函數(shù)一次只能提取一個(gè)
#針對(duì)這個(gè)問題可以設(shè)計(jì)一個(gè)循環(huán) 函數(shù) 一次可以提取index里面的多個(gè)
123456789101112 | f<-function(index,x){ a<-c() for (i in index){ a[i]<-grep(i,x,value= F ) } return (a) } #測試: x<-a index<- c( "A" , "D" , "H" ) f(index,x) |
結(jié)果截圖:
- 5 回答
- 0 關(guān)注
- 1580 瀏覽
添加回答
舉報(bào)