This may be a very basic question but I could't find it. Let's say I have a data frame d
with row numbers in disorder like this:
Signal
4 9998
3 549
1 18
5 2.342
2 0.043
How can I sort this by increasing row index numbers to obtain the following?
Signal
1 18
2 0.043
3 549
4 9998
5 2.342
In order to lead a dataframe with the index ID column, we can also reassign the row names of the dataframe to reflect the increasing integer values starting from 1 to the number of rows in the data frame. The rownames(df) method is used to assign the row names. All the changes are reflected in the original dataframe.
rownames(d) <- 1 : length(rownames(d))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With