I am trying to sort each row of a data frame using this line,
sapply(df, function(x) sort(x))
However, the columns are getting sorted instead of the rows.
For example, this data frame
5 10 7 1 5
6 3 9 2 4
4 5 1 3 3
is ending up like this:
4 3 1 1 3
5 5 7 2 4
6 10 9 3 5
And I want this:
1 5 5 7 10
2 3 4 6 9
1 3 3 4 5
Any recommendations? Thanks