score<-read.csv("D:/季度积分排名.csv") standc<-function(x){ standc<-NULL for (i in 1:length(x)) { standc<-c(standc,(x[i]-min(x))/(max(x)-min(x))) } return(standc) } standd<- function(x){ k<-NULL for (i in 1:length(x)){ if (x[i]>0.7) k<-c(k,1) else if (x[i]<0.35) k<-c(k,3) else k<-c(k,2) } return(k) } team<-score[,2] task<-score[,8] new.score<-cbind(team,task) listnew.score<-tapply(new.score[,2],new.score[,1],standc) lscore<-lapply(listnew.score,standd) result<-NULL for (i in 1:24) result<-c(result,lscore[[i]]) order.score<-score[order(score[,2]),] result.score<-cbind(order.score,result) write.csv(result.score,file="D:/任务结果.csv")
时间: 2024-10-08 13:40:56