library(dplyr)
library(nycflights13)
#Prepare an sample data set;
sample<-flights%>%
select(year,month,day)%>%
group_by(year,month,day)%>%
filter(row_number() == 1)
#Keep only the 6th day from the bottom of each month
final<-sample%>%
group_by(year,month)%>%
arrange(-day)%>%
filter(row_number()==6)