m1<-matrix(round(rnorm(2000),2),100,20)#随即构建一个100*20的矩阵
which.max(apply(m1,2,mean))#均值最大的列
which.max(apply(m1,2,var))#方差最大的列
my_data<-c(m1)
x<-rank(my_data,na.last=TRUE)#rank排序
m1[which(x==2000)]#第一最大值的大小与位置
col1<-ceiling(which(x==2000)%/%100)
row1<-ceiling(which(x==2000)%/%20)
print(col1)
print(row1)
m1[which(x==1999)]#第二最大值的大小与位置
col2<-ceiling(which(x==1999)%/%100)
row2<-ceiling(which(x==1999)%/%20)
print(col2)
print(row2)
cor(m1)#计算每两列间的相关性
m2<-(cor(m1))
m2[m2==1]<-0
cormax<- m2==max(m2)
mydata.cols<-which(cormax,arr.ind=T)#给出两列位置
mydata.cols[1,]
a<-c(mydata.cols[1,])
median1<-median(m1[a[1]])#计算两列中位数
median2<-median(m1[a[2]])
print(median1)
print(median2)
medians<-c(median1,median2)
d<-rank(medians,na.last=T)
median.lower<-which(d==1)
mydata.cols[2,]
b<-c(mydata.cols[2,])
median1<-median(m1[b[1]])#计算两列中位数
median2<-median(m1[b[2]])
print(median1)
print(median2)
medians<-c(median1,median2)
d<-rank(medians,na.last=T)
median.lower<-which(d==1)
m1<-m1[,-b[median.lower]]#删除两列中位数较小的列
m1<-m1[,-a[median.lower]]
m3<-apply(m1,1,var) #计算每行的方差
z<-rank(m3,na.last=TRUE)#获得方差最小的五行行数
row_min1<-which(z==1)
row_min2<-which(z==2)
row_min3<-which(z==3)
row_min4<-which(z==4)
row_min5<-which(z==5)
print(row_min1)
print(row_min2)
print(row_min3)
print(row_min4)
print(row_min5)
#删除方差最小的五行数据
vec<-c(which(z==1), which(z==2), which(z==3), which(z==4), which(z==5))
m1<-m1[-vec,]
print(m1)