vendredi 14 août 2020

Condition mutate rows with specif value with two conditions

I have a huge dataframe and I have to modify rows that contain the value 'js' and if are in corrispondence of another column that display value 'null'. This is an example of my dataframe called d.

I'd like in my example to change the row number 16 for example but my dataframe is much more huge, and I want to change the rows that contain 'js' in 'pexnd' and are in corrispondence of null, while for the other 'js' if they are not in corrispondence of 'null' in the column d$match i want that change them in NA.

I tried with this code:

d %>% mutate_all(d,funs(ifelse(d$match=='null & grepl('js',d1),'pexnd','')))

Aucun commentaire:

Enregistrer un commentaire