duplicate data - R, find duplicated rows , regardless of order -
i've been thinking problem whole night: here matrix:
'a' '#' 3 '#' 'a' 3 0 'i am' 2 'i am' 0 2
.....
i want treat rows first 2 rows same, because it's different order of 'a' , '#'. in case, want delete such kind of rows. toy example simple, first 2 same, third , forth same. in data set, don't know 'same' row.
i'm writing in r. thanks.
perhaps work you. not clear desired output though.
x <- structure(c("a", "#", "0", "i am", "#", "a", "i am", "0", "3", "3", "2", "2"), .dim = c(4l, 3l)) x # [,1] [,2] [,3] # [1,] "a" "#" "3" # [2,] "#" "a" "3" # [3,] "0" "i am" "2" # [4,] "i am" "0" "2" duplicated( lapply(1:nrow(x), function(y){ <- x[y, ] a[order(a)] })) # [1] false true false true
this splits matrix row, sorts each row. duplicated
works on list
s too, wrap whole thing `duplicated find items (rows) duplicated.
Comments
Post a Comment