Re: [R] Recombining Mon and Year values

2023-05-17 Thread Eric Berger
An alternative that does not use the zoo package but uses the built-in constant month.abb df1 <- data.frame(Year = c(2021, 2021, 2021), Mon = c("Mar", "Jan", "Apr")) df1$mon_year <- df1$Year*100 + sapply(df1$Mon, \(x) match(x,month.abb)) sort(df1$mon_year) On Wed, May 17, 202

Re: [R] Recombining Mon and Year values

2023-05-16 Thread Jeff Newmiller
I don't use lubridate, but that package works with Date and POSIXt types, which I do use. Just remember to include a day when converting (1st of month is typical), and use an output format to hide the day when you plot. On May 16, 2023 1:29:27 PM PDT, Jeff Reichman wrote: >R Help > > > >I have

Re: [R] Recombining Mon and Year values

2023-05-16 Thread Jeff Reichman
Ah the zoo package! I was trying with lubridate package. -Original Message- From: Rui Barradas Sent: Tuesday, May 16, 2023 5:04 PM To: Jeff Reichman ; r-help@r-project.org Subject: Re: [R] Recombining Mon and Year values Às 21:29 de 16/05/2023, Jeff Reichman escreveu: > R H

Re: [R] Recombining Mon and Year values

2023-05-16 Thread Rui Barradas
Às 21:29 de 16/05/2023, Jeff Reichman escreveu: R Help I have a data.frame where I've broken out the year and an ordered month values. But I need to recombine them so I can graph mon-year in order but when I recombine I lose the month order and the results are plotted alphabetical.

Re: [R] Recombining Mon and Year values

2023-05-16 Thread Bert Gunter
There are many ways to do this in various R packages. Search on "Plot month-year data in R" or the like and choose that which works best for you. There may be a learning curve involved, naturally. (Note: you may wish to check out zoo:yearmon and zoo:autoplot first, as these seem like they might be