for(i in (1:length(ctry))){ plot.df <- energy[energy$country==ctry[i],] ets.initial <- min(plot.df$year) if(FALSE %in% is.na(plot.df$ETS) # Checks if there is any non-NA value in plot.df$ETS (produce plots and rest of output as planned) }
将是使用基数R的解决方案。