calculate the unique entries and bindrows column

I want to find the unique entries for ID1 and ID2 so if a "aaf" entered the data in id1 and id2 the if will be single entry so here unique entries will 8 from id1 and id2 . i want to assing unique entries in separate variable . you can refer the pic below

then i want to bind the columns one by another like the pic below. final db should be look like binding rows

df <- structure(list(city=c("del","mum","nav","pun","bang","chen","triv","vish","del"),
                      name= c("xab","Lan","mun","mmc","aaf","nnhu","njam","jiha","ntha"),
  `ID 1` = c(653, NA, 240, NA, 826, NA, NA, 440, 
 385), `ID 2` = c(NA, 610, NA, 240, 551, 854, NA, 490, 653),
 `S1`=c(213, 233, NA, NA, 333, 543, 122, NA, 765),
`S1`=c(176, NA, NA, 100, 124, 621, NA, 434, 323)), row.names = c(NA, 
      -9L), class = "data.frame")

i want the output should look like below, i dont want this column with 8

but there are 9 , not 8 ?

distinct(df,`ID 1`,`ID 2`)
#    ID 1 ID 2
# 1  653   NA
# 2   NA  610
# 3  240   NA
# 4   NA  240
# 5  826  551
# 6   NA  854
# 7   NA   NA
# 8  440  490
# 9  385  653

This topic was automatically closed 42 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.