If you just want to plot the summary data using ggplot then you would do:
ggplot(data.frame(cut, meanprice), aes(cut, meanprice)) +
geom_bar(stat = "identity", fill = "grey50")
If you want to skip the summarising step then one way would be:
ggplot(diamonds, aes(cut, price)) +
stat_summary(fun.y = "mean", fill = "grey50", geom = "bar")
But notice the y-axis extends to the range of price. We can't use
ylim here since it will exclude some of the data which we are
summarising over. So instead use coord_cartesian:
ggplot(diamonds, aes(cut, price)) +
stat_summary(fun.y = "mean", fill = "grey50", geom = "bar") +
coord_cartesian(ylim = c(0,5000))
And maybe add in some more breaks in the axis and change its label:
ggplot(diamonds, aes(cut, price)) +
stat_summary(fun.y = "mean", fill = "grey50", geom = "bar") +
coord_cartesian(ylim = c(0,5000)) +
scale_y_continuous("mean_price", breaks = 1000 * 0:5)
Charlotte