Commit 6406b4ad authored by Simon Pintarelli's avatar Simon Pintarelli

bugfix (float comparison)

- allow point increments to be arbitrary (for example 0.01)
- "sane" point increments as 0.25, 0.5, 1,... were not affected by this bug
parent 5cb9e8c3
...@@ -141,13 +141,18 @@ dset$value <- as.numeric(dset$value) ...@@ -141,13 +141,18 @@ dset$value <- as.numeric(dset$value)
total_points <- group_by(dset, Number) %>% summarize(s=sum(value)) total_points <- group_by(dset, Number) %>% summarize(s=sum(value))
linscale <- data.frame(approx(int_points, int_grades, seq(0, maxpoints, by=dp))) linscale <- data.frame(approx(int_points, int_grades, seq(0, maxpoints, by=dp)))
scale <- data.frame(grade=floor(linscale$y*1/dg)*dg, s=linscale$x) FUZZY <- 1e6
grades <- data.frame(left_join(x=total_points, y=scale, by="s")) linscale$jj <- as.integer(round(linscale$x*FUZZY))
scale <- data.frame(grade=floor(linscale$y*1/dg)*dg, jj=linscale$jj)
total_points$jj <- as.integer(round(total_points$s*FUZZY))
grades <- data.frame(left_join(x=total_points, y=scale, by="jj"))
grades <- grades[,c("Number", "s", "grade")]
colnames(grades) <- c("legi", "points", "grade") colnames(grades) <- c("legi", "points", "grade")
grades$legi <- as.factor(grades$legi) grades$legi <- as.factor(grades$legi)
## plot grading scale (linear interpolation and projection to existing marks) ## plot grading scale (linear interpolation and projection to existing marks)
scale_plot <- cbind(linscale, col=rep("linear interpolation", nrow(linscale))) scale_plot <- cbind(linscale, col=rep("linear interpolation", nrow(linscale)))
colnames(scale_plot) <- c("s", "grade", "col") colnames(scale_plot) <- c("s", "grade", "jj", "col")
scale$s <- scale$jj/FUZZY
scale_plot <- rbind(scale_plot, cbind(scale, col=rep("rounded", nrow(linscale)))) scale_plot <- rbind(scale_plot, cbind(scale, col=rep("rounded", nrow(linscale))))
@ @
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment