Remove duplicate values across a few columns but keep rows
问题 I have a dataframe that looks like this: dat <- data.frame(id=1:6, z_1=c(100,290,38,129,0,290), z_2=c(20,0,0,0,0,290), z_3=c(0,0,38,0,0,98), z_4=c(0,0,38,127,38,78), z_5=c(23,0,25,0,0,98), z_6=c(100,0,25,127,0,9)) dat id z_1 z_2 z_3 z_4 z_5 z_6 1 1 100 20 0 0 23 100 2 2 290 0 0 0 0 0 3 3 38 0 38 38 25 25 4 4 129 0 0 127 0 127 5 5 0 0 0 38 0 0 6 6 290 290 98 78 98 9 I want to remove duplicate values of z_x across each row, replacing any duplicates with either a 0 or NA , but leaving the rows &