library(dplyr)

d <- read.csv('school.csv', stringsAsFactors=F)

dd <-
    d[d$rollno < 6, ] %>%
    group_by(school, class) %>%
    summarise(marks=mean(marks))

sapply(seq(1, nrow(dd)-1, 2), FUN=function(i) {
    if (dd$marks[i] == dd$marks[i + 1]) {
        dd[sample(c(i, i+1), 1), ]
    } else {
        dd[ifelse(dd$marks[i] > dd$marks[i + 1], i, i+1), ]
    }
}) %>% t



Created: 14/12/2015
Changed: 14/12/2015
Visits: 253
Online: 0