Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

sorting date column in a dataframe in r

I have a dataframe which looks like this

Date           Temp_value
01.03.2020       100
09.03.2020       10
05.03.2020       111
08.03.2020       112
31.12.2019       135

The date column is not sorted.

I want to sort it in an ascending order for further processing

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Code I used that didnot work:

df[order(as.Date(df$date, format="%d.%m.%Y")),]

Can anyone help me with an alternative

>Solution :

df$Date <- as.POSIXct(df$Date, format="%d.%m.%Y")
df= arrange(df,Date)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading