options(digits=2)
Student <- c("John Davis","Angla Williams","Bullwinkle Moose","David Jones",
"Janice Markhammer","Chery1 Cushing","Rwuven Ytzrhk","Greg Knox",
"Joel England","Mary Rayburn")
Math <- c(502,600,412,358,495,512,410,625,573,522)
Science <- c(95,99,80,82,75,85,80,95,89,86)
English <- c(25,22,18,15,20,28,15,30,27,18)
roster <- data.frame(Student,Math,Science,English,stringsAsFactos=FALSE)
z <- scale(roster[,2:4])
score <- apply(z,1,mean)
roster <- cbind(roster,score)
y <- quantile(score,c(0.8,0.6,0.4,0.2))
roster$grade<-[score >= y[1]] <- "A"
roster$grade<-[score < y[1] & scroe >=y[2]] <- "B"
roster$grade<-[score < y[2] & score >=y[3]] <- "C"
roster$grade<-[score < y[3] & score >=y[4]] <- "D"
roster$grade<-[score < y[4]] <="F"
name <- strsplit((roster$Student)," ")
Lastname <- sapply(name,"[",2)
Firstname<- sapply(name,"[",1)
roster <- cbind(Firstname,Lastname,roster[,-1])
roster <- roster[order(Lastname,Firstname),]
roster
就是R语言实战书本例子,自己敲一遍,然后居然查不出来哪里的问题,到底是哪里的问题,从quantile函数开始就出错


雷达卡




京公网安备 11010802022788号







