Given a toy code
row1 <- c(1,1,1,0,0,0, NA, NA)
row2 <- c(1,1,1,0,0,0, NA, NA)
test <- t(data.frame(row1, row2))
for (j in 1:length(test)) {
binary <- test[, j]
if (binary[1] == 1 &
binary[2] == 1) {
print("A")
}
else if (binary[1] == 1 &
binary[2] == 0) {
print("B")
}
else {
print("NA")
}
}
The espected print out would be:
A, A, A, B, B, B, NA, NA
However, it won't work and I can't see the mistake in the loop.
Aucun commentaire:
Enregistrer un commentaire