Tuesday, March 10, 2015

R code, bio125 midterm grade analysis

#bio125 grades
# Mid-Semester Exam   25%
# Final Exam 25%
# Assignments 25%
# Project Report 10%
# Presentation    10%
# Class Participation     5%

rm(list=ls())

list.files()
flag = 2
tb = read.csv("201501-61954-02 Grades.csv")
#tb = read.csv("201501-61953-01 Grades.csv")
#The - signs have to be replaced with zeros in textwrangler

empty.columns= NULL
for (j in 7:length(tb[1,])){
 tb[,j] = as.numeric( tb[,j])
 tb[is.na(tb[,j]),j] = 0
 if( max(tb[,j])==0 ) { empty.columns = c(empty.columns, j)}
}
str(tb)
tb2 = tb[, - empty.columns]
summary(tb)

names(tb2)[ grep("total", names(tb2)) ]
tb2 = tb2[, -grep("total", names(tb2)) ]
tb2 = tb2[, -grep("assessment", names(tb2)) ]
names(tb2);
sort(names(tb2))
tb3 = tb2[, sort(names(tb2))]

####
#pick highest scores from regular and makeup ones
makeups = grep("make", names(tb3))
regulars = makeups - 1
names(tb3)[c(makeups, regulars)]
for (i in makeups){
  tb3[,i-1]= apply(tb3[,c(i-1,i)], 1, max)
}
tb3[, c(makeups[2]-1, makeups[2])] #passed.
# now, remove makeups
tb4 = tb3[, -makeups]
###end of pick highest grades

#Midterm 25%
names(tb4)[ grep( 'mid', names(tb4)) ]
Midterm = c(  "Quiz.Spring.2015..section.1..midterm..open.part"  ) #section 1
if( flag==2) {
 Midterm = c(  "Quiz.Sp15..Section2..midterm..open.book.part"  )   #section 2
}

#Final 25%
# ....

# Project Report  10%
names(tb4)[ grep( 'port', names(tb4)) ]
Reports = c("Assignment.GoogleDoc.report.of.RE.digestion.lab..group.submission.",    
  "Assignment.Set.up.GoogleDoc.for.final.project.and.report.of.miniprep.lab"
)

# Class Participation     5%
#names(tb4)[ grep( 'note', names(tb4)) ]
names(tb4)[ grep( 'Quiz.lab', names(tb4)) ]
Participation = names(tb4)[ grep( 'Quiz', names(tb4)) ]
Participation = Participation [-grep("lab", Participation )]
#Participation = Participation[-grep("Quiz.Spring.2015..section.1..midterm..open.part", Participation)]
Participation = Participation[-grep(Midterm, Participation)]

#Assignments  #25%
Assignments = names(tb4)[ grep("Quiz", names(tb4)) ]

# Presentation    10%
out= tb4[,c("First.name","Last.name")]

out$Assignments = apply( tb4[,Assignments], 1, sum)
out$Assignments = 25 * out$Assignments / max( out$Assignments )

out$Participation = apply(tb4[,Participation], 1, sum)

out$Participation = 5 * out$Participation / max(out$Participation)

out$exam = tb4[,Midterm]
head(out)
out$total = apply( out[,3:5], 1, sum)
hist(out$total, br=10)



No comments:

Post a Comment