I use the command to return points at which participants reach 8 adjacent answers in a row. Team:
test <- which( rle(goo)$values==1 & rle(goo)$lengths >= 8)
Where:
goo <- c(1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0)
if the participant never reaches 8 contiguous answers, I would like to set the variable "test" to -1. At its core, the command returns an integer (0) when 8 adjacent answers in the string are not found. I tried writing the if command, but it seems I don’t understand.
Thanks in advance,
Will
r
user678493
source share