lundi 8 avril 2019

How to remove leap day from date sequence in R?

Remove leap day in date sequence. Please suggest other easy methods.

I am newbie to R. Here I am trying to remove leapday from my date sequence, however, I am getting error. Please help.

Dates=as.data.frame(seq(as.Date("1979-01-01"), to=as.Date("2016-12-31"),by="days"))
names(Dates)= "Dates"
Dates$year=as.numeric(format(Dates$Dates, "%Y"))
Dates$month=as.numeric(format(Dates$Dates, "%m"))
Dates$day=as.numeric(format(Dates$Dates, "%d"))

if [(Dates$month == 2 & Dates$day == 29)]
    Dates=Dates[]

Date sequence with no leap day

Aucun commentaire:

Enregistrer un commentaire