Hi everyone,
I am trying to do compare every one row with the next in two variables but I got that error, my code is:
base$cambio =0
i=j
for (i in 1:length(base[,1])){ #length of mrun
for (j in 1:length(base[,3])){ #length of rbd, same of mrun
if (base$mrun[i]==base$mrun[i+1] && base$rbd[j]==base$rbd[j+1]){
base$cambio[i]=0}
else {base$cambio[i]=1}
}
}
Error in if (base$mrun[i] == base$mrun[i + 1] && base$rbd[j] == base$rbd[j + : missing value where TRUE/FALSE needed
Hi everyone, I am trying to do compare every one row with the next in two variables but I got that error, my code is:
base$cambio =0 i=j for (i in 1:length(base[,1])){ #length of mrun for (j in 1:length(base[,3])){ #length of rbd, same of mrun if (base$mrun[i]==base$mrun[i+1] && base$rbd[j]==base$rbd[j+1]){ base$cambio[i]=0} else {base$cambio[i]=1} } }
Error in if (base$mrun[i] == base$mrun[i + 1] && base$rbd[j] == base$rbd[j + : missing value where TRUE/FALSE needed