I'm trying to find a way to identify monotone answer patterns of participants in my experiment. For example if someone answered the first Option, coded as "1" in all of the first 10 Questions. I tried to do it with the standard deviation which has to be zero if there is no variance in the answers, but i wasn't successful so far. Here is my attempt:
m.check <- function(data,startrow, endrow){
out <- ifelse(sapply(data, startrow:endrow,sd) ==0,T, F)
return(out)
}
data$mono <- m.check(as.numeric(data,1,10))