I would like to ask how should I implement my code if the condition is if the first condition for x below is 1 & 1 I want my equation to minus 1 on i part only For example : 1/ (29+30) then if the second condition is 2 & 1 then I maintain the i value(carry forward) and minus 1 on j part only So it will become : 1/(29+29)
#There is a total 60 data
x[,1] and x[,2] are two separate categories
for(i in 1:n) {
for(j in 1:n) {
if (x[,2] == 1 && x[,1] == 1) {
y[i] = 1/((30-i)+(30-j))
} else if (x[,2]==2 && x[,1] == 1) {
y[j] = 1/((30-i)+(30-j))
}
}
}
Aucun commentaire:
Enregistrer un commentaire