Simply put, I have the following data frame:
Signal
4 9998
3 549
1 18
5 2.342
2 0.043
and I want to reset the index numbers to be like :
Signal
1 9998
2 549
3 18
4 2.342
5 0.043
The dplyr function arrange() can be used to reorder (or sort) rows by one or more variables. Instead of using the function desc(), you can prepend the sorting variable by a minus sign to indicate descending order, as follow. If the data contain missing values, they will always come at the end.
To sort a data frame in R, use the order( ) function. By default, sorting is ASCENDING. Prepend the sorting variable by a minus sign to indicate DESCENDING order.
Use the square bracket operator with df[] notation to select rows by index in R, The syntax of this notation is df[rows, columns], replace rows with the index number, index range, or list of index values.
You can use
row.names(yourdf) <- NULL
to reset the row names
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