Image of two graphs combined together:
I am currently attempting to make a ggplot with a boxplot and a path plot on the same image, the path plot is supposed to intersect with the median areas of the boxplot itself. For some reason the path plot is stretching far off where it is meant to be. I'm not sure what is causing this error. I have pasted all of the relevant code below. I've tried messing with the language in the ggplot area but nothing seems to fix this.
Bottom <- na.omit(subset.data.frame(Chronosequence, Chronosequence$vegetation_zone == "bottom"))
Transition <- na.omit(subset.data.frame(Chronosequence, Chronosequence$vegetation_zone == "transition"))
Edge <- na.omit(subset.data.frame(Chronosequence, Chronosequence$vegetation_zone == "edge"))
EdgeMean <- (Edge) %>% group_by(time_since) %>%
summarize(average = median(sum_of_non_native_cover_automatically_calculated)) %>%
ungroup()
#### Plotting####
boxplot(Edge$sum_of_non_native_cover_automatically_calculated ~ Edge$time_since,
xlab="Years Since Restoration Finished",
ylab="Percent Cover of Non-Native Species")
ggplot() +
geom_boxplot(mapping = aes(
factor(x = Edge$time_since), y = Edge$sum_of_non_native_cover_automatically_calculated))+
geom_path(mapping = aes(x= EdgeMean$time_since, y=EdgeMean$average))

subsetyou should remove the data.frame name from the filter condition. Keep the column name,subset(Chronosequence, vegetation_zone == "transition")is much better.