# NOT RUN {
# number of simulated questions in exam
n.sim.questions <- 10
base.names <- c('John', 'Marcelo','Ricardo', 'Tarcizio')
last.names <- c('Smith', 'P.')
name.grid <- expand.grid(base.names,last.names)
my.names <- paste(name.grid[,1], name.grid[,2])
# official names from the university system (will assume it is equal to my.names)
# In a practical situation, this list of official names will come from the university system
exam.names <- my.names
set.seed(10)
correction.mat <- matrix(sample(c(TRUE,FALSE),
size = length(exam.names)*n.sim.questions,
replace = TRUE),nrow = length(exam.names))
idx.cheater.1 <- 5 # std 5 and 6 have simillar correct answers
idx.cheater.2 <- 6
proportion.to.cheat <- 0.5 # proportion of same correct answers
q.to.cheat <- floor(proportion.to.cheat*n.sim.questions)
correction.mat[idx.cheater.1, ] <- c(rep(TRUE,q.to.cheat),
rep(FALSE,n.sim.questions-q.to.cheat))
correction.mat[idx.cheater.2, ] <- correction.mat[idx.cheater.1, ]
df.grade <- cbind(data.frame(exam.names),correction.mat)
test.cheating.out <- rte.test.cheating(df.grade, do.cheat.plot = FALSE )
# }
Run the code above in your browser using DataCamp Workspace