I am looking for an R function that allows swapping two elements in a data frame under a certain constraint.
For example:
If I have a dataframe (5rows, 5cols) and I want that all elements in column 2 that are greater than the corresponding elements in column 3 to be swapped. As a result, all the elements of column 2 greater than those of column 3 would move to column 3 and vice-versa.
Your help is much appreciated.