I am new with R and got stuck with this loop code. I want to see in which rows column 3 values and column 2 values are unequal.
I have created a data frame list, by extracting columns from a dataset PFC_DATA.
list <- as.data.frame(PFC_Data[ ,c(1,6,10)])
And then created the loop with two conditions. Since the column 3 has a bunch of NAs, if it is an NA, then skip, otherwise, if column 3 has a value that is unequal to column 2 value, print the row numbers. That's the code:
`
for (i in 1:1840) {
if (list[[3]][[i]] == is.na())
next
else {
if (list[[3]][[i]] != list[[2]][[i]]) {
print(i)
}
}
}
`
I also tried =="NA". However, in either case nothing happens. I do not get any error, but no output either. Any ideas?
Aucun commentaire:
Enregistrer un commentaire