mercredi 26 juin 2019

Where is the problem that ifelse statement does not work

I am working with the following dataset:

a<-data.frame(cell<-c( 70,26.171255,79,18.725711,129,17.130182,                          7.073919))


And i tried to put missing values for the certain values with this code:

 for (i in 1:nrow(a)) {
      a[i,1] <- ifelse(a[i,1] %in% c(17.130182,18.725711,26.171255), NA,a[i,1])
    }


It is working well. However if I do from the another dataset (whole sample - 330 rows) using the code

a<-data.frame(value$tobinsq)

, it turns out that the code does not work. dataset value is put as a data frame in R.

Where can be the problem?

Aucun commentaire:

Enregistrer un commentaire