I need to plot a histogram graph with six countries in the x axis and their gdp in the y axis, how should I write the qplot function? I use: qplot(x = countrygdp, y = gdp, data = combined, geom = "histogram”) However, it just keep giving me errors saying that I should use stat=“bin” or something. Anyone knows how to solve this?
Asked
Active
Viewed 323 times
-3
-
1Welcome to SO. Please provide a reproducible example: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example . To your question: why not take `ggplot` like `combined <- data.frame(f = gl(2, 100), x = runif(200)); ggplot(combined, aes(x = x)) + geom_histogram() + facet_grid(~f)`. – lukeA Apr 22 '15 at 07:08
1 Answers
0
You should use stat=identity
to tell ggplot to use the gdp values without any transformation.
combined <- data.frame(countrygdp=letters[1:6],gdp=runif(6))
library(ggplot2)
qplot(x = countrygdp, y = gdp, data = combined, geom ="histogram",stat="identity")

scoa
- 19,359
- 5
- 65
- 80