mercredi 13 juillet 2016

How to perform an if then for each instance of a variable in a dataframe in R

I am trying to set NA values in a dataframe to 0 if the id for the row is included in a separate list, but am getting either nothing (no changes no error), or this error:

the condition has length > 1 and only the first element will be used

My code is below. Any help is appreciated!

if(is.na(dset_n$bet3) && dset_n$id %in% unique(net_t3[,1])) {
  dset_n$bet3 <- 0
}

Aucun commentaire:

Enregistrer un commentaire