Error in FUN(X[[i]], ...) : object 'group' not found

I am trying to plot a map for each year within a range using the following code and am getting the error
Error in FUN(X[[i]], ...) : object 'group' not found
The ggplot portion of the code runs fine but then I get an error from the plot.list[[1]] line and on.

Does anyone know how to fix this error? Thanks.

ggtitle.names<-paste(2005:2020)
plot.list<-list()
for(i in 1:length(unique(datum.inside$YEAR))){
fig<-ggplot()+
geom_polygon(data=kscoords,aes(x=X1,y=X2,group=group),
color="black",fill="white",size=0.25)+
expand_limits(x = datum.inside$LONG, y = datum.inside$LAT)+
geom_point(data=datum.inside.total.by.year.cwd[[i]],aes(x=LONG,y=LAT,col=CWD_RESULT,shape=CWD_RESULT))+
geom_path(inherit.aes = FALSE)+
scale_color_manual(values=c("green","red","blue"))+
ggtitle(ggtitle.names[i])+
theme(plot.title = element_text(hjust = 0.5,size=40))+
theme(axis.title=element_text(size=25))+
theme(legend.title=element_text(size=25))+
theme(legend.text=element_text(size=25))+
xlab("longitude")+
ylab("latitude")+
coord_map("albers",parameters=c(39,45))
plot.list[[i]]<-fig

}

plot.list[[1]]
plot.list[[2]]
plot.list[[3]]
plot.list[[4]]
plot.list[[5]]
plot.list[[6]]
plot.list[[7]]
plot.list[[8]]
plot.list[[9]]
plot.list[[10]]
plot.list[[11]]
plot.list[[12]]
plot.list[[13]]
plot.list[[14]]
plot.list[[15]]
plot.list[[16]]

Hi!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.