mercredi 24 février 2021

Without removing i would like to subset the rows in the dataframe and run an ifelse through the subset?

{df %>% filter(value %in% list)}$GOOD_Outcome<-ifelse(
                           df$column1 =="Y"&
                           df$column2 !="N"&
                           df$column3!=""&
                           df$column4 !="N"&
                           df$column5 !="",
                         "Yes", "No")

I get an error message

 Error in `$<-.data.frame`(`*tmp*`, GOOD_OUTCOME, value = c("No", "No", "No",  : 

replacement has 977 rows, data has 33

I want the script to disregard the 944 other rows and run the ifelse within the confines of the 33 rows. Is there a way to do this?

Aucun commentaire:

Enregistrer un commentaire