checks cells are empty

I have a data frame below
1)i am trying to check if both columns are empty , if empty then mutate new column to 2) also checking if all the mail id's in email is unique , if duplicate then mutate new column to one.

df <- data.frame(name=c("maay,bhtr","nsgu,nhuts thang","affat,nurfs","nukhyu,biyts",NA,"nsgyu,noon","utrs guus,book","thum,cryant","mumt,cant","bhan,btan","khtri,ntuk","ghaan,rstu","shaan,btqaan","nhue,bjtraan","wutys,cyun","hrtsh,jaan"),
                 email=c("maay.bhtr@email.com",NA,"asfa.1234@gmail.com","nukhyu.biyts@gmail.com","ngyst.muun@gmail.com","nsgyu.noon@gmail.com","utrs.book@hotmail.com","thum.cryant@live.com","mumt.cant@gmail.com","maay.bhtr@email.com","khtri.ntuk@gmail.c.om","chang.lee@gmail.com","shaan.btqaan@gmail.com","nhue.bjtraan@gmail.com","wutys.cyun@gmailcom","hrtsh.jaan@gmail.com"))

df[is.na(df)] <- ""


df <- df %>% mutate(is_blank_node = which(df$name == "", arr.ind = TRUE),1 )

df <- df %>% group_by(email) %>% 
  mutate(Flag=1:n(),`Duplicate_ID`=ifelse(Flag==1,0,1)) %>% select(-Flag)

the output should be like

name email name_blank email_blank duplicate_email
maay,bhtr maay.bhtr@email.com 0 0 0
nsgu,nhuts thang 0 1 0
affat,nurfs asfa.1234@gmail.com 0 0 0
nukhyu,biyts nukhyu.biyts@gmail.com 0 0 0
ngyst.muun@gmail.com 1 0 0
nsgyu,noon nsgyu.noon@gmail.com 0 0 0
utrs guus,book utrs.book@hotmail.com 0 0 0
thum,cryant thum.cryant@live.com 0 0 0
mumt,cant mumt.cant@gmail.com 0 0 0
bhan,btan maay.bhtr@email.com 0 0 1
khtri,ntuk khtri.ntuk@gmail.c.om 0 0 0
ghaan,rstu chang.lee@gmail.com 0 0 0
shaan,btqaan shaan.btqaan@gmail.com 0 0 0
nhue,bjtraan nhue.bjtraan@gmail.com 0 0 0
wutys,cyun wutys.cyun@gmailcom 0 0 0
hrtsh,jaan hrtsh.jaan@gmail.com 0 0 0

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.