hockeyviz <- quanthockey3 %>%
mutate(Name = fct_reorder(Name, A+G)) %>%
ggplot(aes(x=A+G, y=Name, fill = test)) + geom_col(color="black", fill="lightblue") +
labs(title="Top 10 NHL Point Totals", x="Points", y="Player Name")
hockeyviz
I am trying to create a stacked bar graph utilizing goals and assists, however I cannot understand how to go about this when dealing with two numerical columns as opposed to two categorical values. I have researched this relentlessly but cannot find any examples or help.
Any help on this matter is greatly appreciated along with code structure advice. Thank you!
Thank you! I was researching pivot_longer() but it was quite confusing to me, so I will have to research it more. My friend that is an experienced coder in other languages helped me to manually create a dataset like this:
pivot_longer() — and its complement, pivot_wider()— are worth getting to know. ggplot(), like other packages in the tidyverse, work best with tidy data.
There's a lot of good information and learning tools about tidyverse packages and tidy data generally over on the tidyverse web site.