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

How to order years by month?

Assuming:

     s1=seq(as.Date("1950/01/01"), by = "month", length.out = 200)

Will give:

     1950-01-01
     1950-02-01
     1950-03-01
     1950-04-01

this is one comuln in a dataframe, I would like to arragne the whole datafram:

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

   1950-01-01
   1951-01-01
   1952-01-01
   1953-01-01

>Solution :

s1[order(lubridate::month(s1))]

or to order by month and by year

s1[order(lubridate::month(s1), lubridate::year(s1))]

in a data.frame

df[order(lubridate::month(df$s1), lubridate::year(df$s1)), ]
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