Skip to content
Prev 386846 / 398502 Next

Converting "day of year" to "year", "month" and "day"

Hi Jibrin,
solar_wind_sps<-data.frame(sws=306,date="2021-016")
solar_wind_spd
solar_wind_spd$date<-as.Date(solar_wind_spd$date,"%Y-%j")
solar_wind_spd

This changes the "date" field to an actual date object. If you just
want to change a character string date to another format:

solar_wind_spd$date<-format(as.Date(solar_wind_spd$date,%Y-%j),"%Y-%m-%d")

Jim

On Sat, Jan 16, 2021 at 4:55 AM Jibrin Alhassan
<jibrin.alhassan at unn.edu.ng> wrote: