sorting - Change row names in R, sort by date -
this question has answer here:
- how reset row names? 1 answer
i have dataframe of first column date object (used lubridate) , other columns show number of items sold. i'm having issues row names (numbers). is, row names not in order of dates:
i tried using rownames, can't figure out how sort row names date, july 28 becomes '2', july 29 becomes '3', etc. have way achieve this? if additional information needed, please let me know. in advance!
you can use built-in order
function:
newdata <- df[order(df$date),]
if rownames persist out of order, can reset them:
rownames(newdata) <- null
wiki
Comments
Post a Comment