d <- aggregate(Petal.Length~Species, data = iris, FUN = mean)
Species Petal.Length
1 setosa 1.462
2 versicolor 4.260
3 virginica 5.552
barplot(Petal.Length~Species, data = d)
使用ggplot2图形 package,您可以:
library(ggplot2)
ggplot(d, aes(x = Species, y = Petal.Length))+
geom_col()