简体   繁体   中英

How to build Plot Histogram in R with multiple variables?

Anyone help me to build histogram of this dataset?

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

Thank you!

enter image description here

You could use 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)

在此处输入图像描述

Using the ggplot2 graphical package, you can do:

library(ggplot2)

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

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM