How to tune frequency with ggplot2?

I have a molten dataset containing a โ€œvalueโ€ column, which is an absolute number that depends on each row of the dataset. I want to display this number in barchart by country.

p <- ggplot(melted,aes(factor(country),y=as.numeric(value))) + geom_bar() +opts(axis.text.x = theme_text(angle = 90,hjust = 1)) 

all i get:

Error in pmin (y, 0): Objekt 'y' not found.

Of course, I am triple-checked, if there was a variable "value", I just can not find what is wrong. If you leave y = ..., I get country observations that are the same for each country in my case.

+4
source share
1 answer

You may need to define statistics statistics in geom_bar() .

  ggplot(melted,aes(factor(country),y=as.numeric(value))) + geom_bar(stat = "identity", position = "stack") 
+5
source

All Articles