I have the following type of dataframe
A B C D
1 0 1 10
0 2 1 15
1 1 0 11
I would like the following output
A B C D
1 0 1 10
1 1 0 11
0 2 1 15
I have tried this code
require(permute)
z <- apply(permute::allPerms(1:nrow(DF)), 1, function(x){
mat <- as.matrix(DF,2:ncol(DF)])
if(all(diag(mat[x,]) == rep(1,nrow(DF)))){
return(df[x,])} })
I am unable to get the desired output.
(Link for the above code- Arrange data frame in a specific way)
I request someone to guide me. The dataframe is a small sample but I have a huge one with a similar structure.