Reputation: 337
Here is my code:
tst <- data.frame(ref=c("A", "T", "C", "C", "G", "G"),
alt= c("AAA", "T", "A", "ATCGA", "G", "A"))
for(i in 1:nrow(tst)){
if(tst[i,2] == "A"){
tst <- tst[-i,]
}
}
but I received this error :
Error in if (tst[i, 2] == "A") { : missing value where TRUE/FALSE needed
Now I don't know how to solve it, Thanks for any help
Upvotes: 1
Views: 1142
Reputation: 84659
When i=3
, one has tst[i,2] == "A"
, so tst
is transformed: tst <- tst[-3,]
. Originally, tst
has 6 rows, but now it has only 5 rows. And you get the 'missing value' message when i
reaches 6, because there's no row 6 anymore.
Upvotes: 2