I ran into a sort of error here to pipe ggplot.
every time I pipe a function for ggplot it changes the output of the function and does not print the graphic.
If the same is made but not piping ggplot together, it runs properly.
ggplot no piping
ggplot piping
error on output when piped.
does someone have some idea how to troubleshoot it?
CODE:
overall_avg <- ct_yd_w %>%
group_by(year) %>%
summarise(yield_average = mean(yield_lb_ac, na.rm = TRUE)) %>%
ggplot(aes( x = year, y = yield_average))+
geom_line(size = 0.53)+
theme_bw()+
labs(title = "Cotton yields average over time",
x = "Year",
y = "Average yield (lb/ac)"
)+
theme(plot.title = element_text(hjust = 0.5, size = 14))+
scale_x_continuous(breaks = seq( 1928,2022, by = 10 ), limits = c(1928, 2022))
I couldn't figure out the error in the warning which states "could not find function %>%"
However for not showing plot after the code chunk there might be two reasons:
You are assigning all the pipe functions to a object "overall_avg". Maybe if you remove overall_avg from code 167 and just start with ct_yd_w it might work
Another way after 178, I think if you just plot(overall_avg) it might work.
Hello everyone.
I ran into a sort of error here to pipe ggplot. every time I pipe a function for ggplot it changes the output of the function and does not print the graphic. If the same is made but not piping ggplot together, it runs properly.
ggplot no piping
ggplot piping
error on output when piped.
does someone have some idea how to troubleshoot it?
CODE: overall_avg <- ct_yd_w %>% group_by(year) %>% summarise(yield_average = mean(yield_lb_ac, na.rm = TRUE)) %>% ggplot(aes( x = year, y = yield_average))+ geom_line(size = 0.53)+ theme_bw()+ labs(title = "Cotton yields average over time", x = "Year", y = "Average yield (lb/ac)" )+ theme(plot.title = element_text(hjust = 0.5, size = 14))+ scale_x_continuous(breaks = seq( 1928,2022, by = 10 ), limits = c(1928, 2022))