When I order a data frame by the values of a column using the function "order", I get the rows reordered but they preserve rownames, which they are numbers if I am not using rownames in my data frame.
Example:
mydf <- data.frame(first_name=c("Arya", "Cersei", "Daeneris"), age= c(11, 32, 19))
mydf
mydf <- mydf[order(mydf$age, decreasing=T),]
mydf
Edit: This produces a data frame with the row names preserving the previous row order:
first_name age
2 Cersei 32
3 Daeneris 19
1 Arya 11
I have looked into "order" help, but I don't find any argument to drop the row names. Is there any way to do that even using a different function to reorder rows?
I know I can use rownames(mydf)=NULL
but I would like to do it in the order function if possible.
Edit: desired output would be:
first_name age
1 Cersei 32
2 Daeneris 19
3 Arya 11