zoukankan      html  css  js  c++  java
  • 成绩的处理

    #设置小数点后位数
    options(digits=2)
    name=c("John Davis","Angela Williams","Bullwinkle Moose",
           "David Jones","Janice Markhammer","Cheryl Cushing","Reuven Ytzrhak",
           "Greg Knox","Joel England","Mary Rayburn")
    math=c(502,600,412,358,495,512,410,625,573,522)
    eng=c(25,22,18,15,20,28,15,30,27,18)
    sci=c(95,99,80,82,75,85,80,95,89,86)
    scoreData=data.frame(name,math,sci,eng,stringsAsFactors=FALSE)
    #成绩的标准化
    x=scale(scoreData[,2:4])
    #求平均
    score=apply(x,1,mean)
    scoreData=cbind(scoreData,score)
    y=quantile(score,c(0.8,0.6,0.4,0.2))
    #评等级
    scoreData$grade[score>=y[1]]="A"
    scoreData$grade[score<y[1]&score>=y[2]]="B"
    scoreData$grade[score<y[2]&score>=y[3]]="C"
    scoreData$grade[score<y[3]&score>=y[4]]="D"
    scoreData$grade[score<y[4]]="F"
    nametemp=strsplit(scoreData$name," ")
    lastname=sapply(nametemp,"[",2)
    fristname=sapply(nametemp,"[",1)
    scoreData=cbind(fristname,lastname,scoreData[-1])
    scoreData=scoreData[order(lastname,fristname),]

    最终scoreData为:

  • 相关阅读:
    uniapp
    vue -element admin 修改request,headers添加参数
    uniapp
    css
    uniapp
    uniapp
    vue
    vue
    vue -element 修复select下拉框在移动端需要点击两次才能选中的问题
    vue
  • 原文地址:https://www.cnblogs.com/sklww/p/3519680.html
Copyright © 2011-2022 走看看