r语言矩阵列按某一向量排列

Python013

r语言矩阵列按某一向量排列,第1张

temp = matrix(1:16,4,4)

dimnames(temp) = list(c("c1","c2","c3","c4"),c("c4","c2","c1","c3"))

temp = temp[,order(colnames(temp))]

tempA <- c(1,2,3,6,7,9)

tempB <- c(2,6,7)

tempC <- tempA[-tempB]# 注意有个负号

print(tempC)

static void(int[]group)

{

int temp

int pos=0

for(int i=0i<group.Length-1i++)

{

pos=i

for(intj=i+1j<group.Lengthj++)

{

if(group[j]<group[pos])

{

pos=j

}

}//第i个数与最小的数group[pos]交换

temp=group[i]

group[i]=group[pos]

group[pos]=temp

}

}