Ok this should be easy but I can NOT figure it out. I have data that is called avePrice (using diamond information in ggplot2):
Fair Good Very Good Premium Ideal
282.0 3050.5 2648.0 3181.0 1809.0
I want to plot, using the headings (the first row) on the x-axis as labels and the values (second row) on the y-axis.
This seems it should be easy in R but I cannot seem to figure it out!
I can do this
qplot(x=c("Fair", "Good", "Very Good", "Premium", "Ideal"), y=avePrice, geom="bar", xlab="Diamond Cut", ylab="Average Price")
which works, but it would seem there HAS to be a simple way to do this without typing in the xlabels manually? Hopefully?
Thanks in advance… I’m expecting to feel dumb when someone points out how 🙂
Clarification: I know I can move the x=c(“Fair…”) stuff out of the qplot command and have it elsewhere, but I still am having to manually enter it at that point.
You can directly plot this using
ggplot2without having to calculate the average prices by cut. Here is a one-liner