R: Extracting unique values ​​in columns of a data frame

I have a data frame in R, and I wonder if it is possible to get the column values ​​that are not in the remaining columns, and this is for each column.

My dataframe looks like : sample_1 sample_2 sample_3 aaacec dfe gmj mnn xuw tzz 

I would like to get the following result:

 sample_1 sample_2 sample_3 dfj guw x t 

Thank you in advance for your answers,

+7
r unique dataframe
source share
1 answer

You can try

 lst <- lapply(seq_along(df1), function(i) df1[,i][!df1[,i] %in% unique(unlist(df1[-i]))]) library(stringi) as.data.frame(stri_list2matrix(lst, fill='')) 
+5
source share

All Articles