How to pass the variable y to ggplot in R

ggplot2

#1

Hello,

I have some aggregated data:

And I want to display the store_sales by product_category using ggplot.I am using the below code:

ggplot(data = agg_sales_pcat, aes(x = product_category,y = store_sales,fill = product_category,stat = 'identity'))+
  geom_bar(aes(x = product_category,y = store_sales,fill = product_category,stat = "identiy"))

However I am getting an error saying:
Uploading…

Can someone please help me on how to resolve this error?


#2

Hi

you have build a complicated statement:
ggplot( data = agg_sales_pcat, aes( x=product_category, y = store_sales, fill=product_category ) ) +
geom_bar( stat="indentity )

little example:
test <-data_frame( product_category =c(“Backing Powdee”, “Tutut”, “Hello”), Sales =c(145, 56, 10))
ggplot(data=test, aes(x=product_category, y= Sales, fill= product_category))+geom_bar(stat=“identity”)

With fancy colors :smile:
Alain