码迷,mamicode.com
首页 > 其他好文 > 详细

第一次写的程序

时间:2015-05-08 12:19:14      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

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")

  

第一次写的程序

标签:

原文地址:http://www.cnblogs.com/xiongchang18/p/4487018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!