I'm trying to plot some results from models based of unmarked occupancy frames on graphs using the ggplot2 package. For a dataset of 39 transects, there was no error message and the same piece of code as I have below produced a nice set of graphs. However, I'm now running the code with models constructed from a dataset of 111 samples. Only now do I have an error message, which rather suggests the problem is due to the size of the dataset!
#THIS IS THE CODE THAT WORKS/PRODUCES GRAPH
(wf_RAN <- update(m.RAN, formula = ~ 1 ~ Rang_Dist))
preddata <- predict(wf_RAN, type = "state", appendData = TRUE)
wf_RAN=qplot(Site.Covs.Wolves1$Rang_Dist, Predicted, data = preddata, geom = "line",
xlab = "Distance from Ranger Post (km)", ylab = "Estimated occupancy", ylim=c(0, 1)) +
geom_ribbon(aes(x = Site.Covs.Wolves1$Rang_Dist, ymin = lower, ymax = upper), alpha = 0.1) +
theme_bw()+#sets the background of the plot to white
theme(axis.text=element_text(size=13),axis.line=element_line(colour="black"),
axis.title=element_text(size=15,vjust=0.8),
panel.grid.major = element_blank(),#remove grid lines in background
panel.grid.minor = element_blank(),
legend.text=element_text(size=25),
panel.border = element_blank())
wf_RAN
# Wolf Habitat Use and distance from ranger post (proxy for prey availability)
#Code below does not produce a graph i.e. is the larger dataset of same format
(wf_RAN2 <- update(m.RAN2, formula = ~ 1 ~ Rang_Dist))
preddata <- predict(wf_RAN2, type = "state", appendData = TRUE)
wf_RAN2=qplot(Site.Covs.Wolves1$Rang_Dist, Predicted, data = preddata, geom = "line",
xlab = "Distance from Ranger Post (km)", ylab = "Estimated occupancy", ylim=c(0, 1)) +
geom_ribbon(aes(x = Site.Covs.Wolves1$Rang_Dist, ymin = lower, ymax = upper), alpha = 0.1) +
theme_bw()+#sets the background of the plot to white
theme(axis.text=element_text(size=13),axis.line=element_line(colour="black"),
axis.title=element_text(size=15,vjust=0.8),
panel.grid.major = element_blank(),#remove grid lines in background
panel.grid.minor = element_blank(),
legend.text=element_text(size=25),
panel.border = element_blank())
wf_RAN2
Error: Aesthetics must be either length 1 or the same as the data (39): x
With the dataset of 39 I produced a line graph. The datasets are of the same format just that the second one is larger.
My key question therefore is, what are 'aesthetics' - are they referring to the graph axes? How do I adjust them so that I can plot graphs with a larger dataset?
Or, have I completely misunderstood this problem?