Reputation: 73
I've inserted a table to make it clearer, basically, I'm trying to find a way to get rid of other columns that are identical in the values it has to another one, a duplicate column.
As we can see in the image, Col 2 and 4 are identical, I want to remove Col 4, because for my use it's not helping and is unneeded data.
Thanks!
Upvotes: 1
Views: 44
Reputation: 887028
We can use duplicated
on the transpose of the dataset to create a logical index and use that to subset the columns
df1[!duplicated(t(df1))]
# Col1 Col2 Col3 Col5
#1 1 2 3 1
#2 2 3 4 2
#3 3 4 1 4
#4 4 1 2 3
Upvotes: 3