I am trying to separate a data frame, based on month and year, into several smaller data frames. So I used a loop to extract data frame which fulfills the month and year conditions (see code below).
However, in some situations, data from certain months are not available in a specific year, and by using the code below, it creates empty data frames. Is there a way to avoid it?
Weather.df = read.table(file = "D:/Program Files/R Projects/Weather_Pattern/Weather.txt", header = TRUE, sep = ",")
for (YEAR in min(Weather.df$year):max(Weather.df$year)){
for (MONTH in month.abb){
temp.df = subset(Weather.df, month == MONHT & year == YEAR)
assign(paste(YEAR,MONTH,"luna",sep="."), temp.df)
}
}