NEED help with GEOM_BAR

I am new to RStudio, Most of the time i dont even know what i am doing. Today I am trying to build a bar chart, where I want to show Jurisdiction on X axis and Full year liability on Y axis and color by PELE.
ggplot(data = new, aes(y=Jurisdiction, x=Full_Year_Liability)) + geom_bar(Color=PELE)
Error in layer(data = data, mapping = mapping, stat = stat, geom = GeomBar, :
object 'PELE' not found

I am getting this error message. how do I fix it? Also, if I want create separate bar chart using a column name Scenario, how do i do it?
image

When using {ggplot2}, when you are mapping columns to different geometric features (axes, colors, shapes, etc.) you need to make sure that the mapping is wrapped in aes().

Your code should look like:

ggplot(new, aes(y=Jurisdiction, x=Full_Year_Liability)) + 
  geom_bar(aes(color=PELE))

Hi @JackDavison ,
I am still getting errors
Error: stat_count() can only have an x or y aesthetic.
Run rlang::last_error() to see where the error occurred.

Use geom_col() instead

ggplot(new, aes(y=Jurisdiction, x=Full_Year_Liability)) + 
  geom_col(aes(color=PELE))
1 Like

THAT WORKS. THANK you so much

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.