Take the 2-minute tour ×  I have a data frame that looks like
this:   What I would like is to use the column month to specify
intervals for each season and return those values in a new
column from the same data frame. I was using this code for the
seasons, which seems to work fine,  # Classify months into
seasons   # Create a new column with seasons  for(i in
1:nrow(df)){
if(df$month[i]%in%summer){df$season[i]<-"1-summer"} else
if(df$month[i]%in%fall){df$season[i]<-"2-fall"} else
if(df$month[i]%in%winter){df$season[i]<-"3-winter"} else
However, this loop in already inside of a bigger loop with more
complex and bigger data bases. So I was looking for a faster,
more efficient approach. The reason that I am using a loop
rather than cutting or subsetting my original data frame is
because the first loop that I am using is separating and
performing analyses on individual animals. The length of
resulting data frame varies between animals and one of the
problems that I was having is that not all animals