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

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


鸿蒙传说
浏览 3534回答 5
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.

蓝山帝景

1、sort()函数描述:对给定区间所有元素进行排序。sort()函数语法:sort(begin,end),表示一个范围。2、sort()函数举例:123456789#include&nbsp;<algorithm>#include&nbsp;<iostream>using&nbsp;namespace&nbsp;std;main(){int&nbsp;a[11]={2,4,8,5,7,1,10,6,9,3};//a的长度=待排数据个数+1sort(a,a+10);//对[a,a+10)排序for(int&nbsp;i=0;i<10;++i)&nbsp;cout<<a[i]<<endl;}

哈士奇WWW

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

叮当猫咪

R里没有专门的十六进制类型吧,你是不是输入的是表示十六进制数的字符串啊?是的话要先用strtoi()转换成R里的整数类型,再排序。

幕布斯7119047

例如12substr("abcdef",&nbsp;2,&nbsp;4)&nbsp;#&nbsp;提取第2到第4位置的元素[1]&nbsp;"bcd"&nbsp;获得位置 应该用 grep( )1234567a<-LETTERS[1:8]#输出的#>&nbsp;a#[1]&nbsp;"A"&nbsp;"B"&nbsp;"C"&nbsp;"D"&nbsp;"E"&nbsp;"F"&nbsp;"G"&nbsp;"H"&nbsp;grep("D",a,value=F)#&nbsp;结果&nbsp;[1]&nbsp;4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;D在a&nbsp;中的第四个# 缺点是这函数一次只能提取一个#针对这个问题可以设计一个循环 函数 &nbsp;一次可以提取index里面的多个123456789101112f<-function(index,x){a<-c()for&nbsp;(i&nbsp;in&nbsp;index){&nbsp;&nbsp;&nbsp;&nbsp;a[i]<-grep(i,x,value=F)}return(a)}&nbsp;#测试:x<-aindex<-&nbsp;c("A","D","H")f(index,x)结果截图:
打开App,查看更多内容
随时随地看视频慕课网APP