Hi everyone,
I am trying to create a Season variable from my data set which has a column for Date and a Column for time (which I have made "datetime"). I have two data sets that I am working with at the same time (they are set up in the exact same way they are just from two different field sites). For the LB site the code works perfectly and I get the observations broken up into seasons.
> LB2$datetime<-paste(LB2$DATE,LB2$TIME)
>
> LB2$datetime<-strptime(LB2$datetime,format="%d/%m/%Y %H:%M")
> LB2$month<-as.numeric(format(LB2$datetime,"%m"))
> LB2$season<-"summer"
> LB2$season[LB2$month>2&LB2$month<5]<-"autumn"
> LB2$season[LB2$month>4&LB2$month<9]<-"winter"
> LB2$season[LB2$month>8&LB2$month<12]<-"spring"
> LB2$season<-factor(LB2$season,levels=c("summer","spring","winter","autumn"))
> summary(LB2$season)
summer spring winter autumn
6164 1989 20928 11801
However when I run the same code for the NG site it doesn't work and classes everything as Summer. I am really stuck as to what I am doing wrong (I am still pretty new to R)
> NG1$datetime<-paste(NG1$DATE,NG1$TIME)
> NG1$datetime<-strptime(NG1$datetime,format="%d/%m/%Y %H:%M")
> NG1$month<-as.numeric(format(NG1$datetime,"%m"))
> NG1$season<-"summer"
> NG1$season[NG1$month>2&NG1$month<5]<-"autumn"
> NG1$season[NG1$month>4&NG1$month<9]<-"winter"
> NG1$season[NG1$month>8&NG1$month<12]<-"spring"
> NG1$season<-factor(NG1$season,levels=c("summer","spring","winter","autumn"))
> summary(NG1$season)
summer spring winter autumn
56226 0 0 0