I have data, similar to that in this question, from which I am directly taking Matthew Lundberg's code as an example.
y = data.frame(Specie=c('A','V','R','P','O'),Number=c(18756,8608,3350,3312,1627))
It is demonstrated how to create a barplot using the barplot
command:
barplot(y$Number, names.arg=y$Specie)
How would I do the same thing using ggplot2
or qplot
?
The following does not work:
library(ggplot2)
y = data.frame(Specie=c('A','V','R','P','O'),Number=c(18756,8608,3350,3312,1627))
qplot(x=y[,2], y=y[,1], geom="bar", stat="identify")
What to do?