leombastos / 2024_ppa

1 stars 5 forks source link

Issue piping before ggplot #25

Open Vincius-Trevisan opened 8 months ago

Vincius-Trevisan commented 8 months ago

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_nopipe ggplot no piping

ggplot_pipe ggplot piping

output 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))

ujjwalsigdel commented 8 months ago

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:

  1. 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
  2. Another way after 178, I think if you just plot(overall_avg) it might work.