如何在 R 中使用多个变量构建 Plot Histogram?

How to build Plot Histogram in R with multiple variables?

有人帮我建立这个数据集的直方图吗?

dat2 <- data.frame(mean_setosa, mean_versicolor, mean_virginica)

谢谢!

enter image description here

你可以使用 barplot:

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 图形包,您可以:

library(ggplot2)

ggplot(d, aes(x = Species, y = Petal.Length))+
  geom_col()