R 中 2 类 的频率图
Frequency Plot with 2 classes in R
我有一个包含 2 个特征的数据框,第一个是类 'Yes' 或 'No',第二个是“JobSatisfaction”。我想画这样的东西。
https://i.stack.imgur.com/oWzV1.png
我在这里计算变量 JobSatisfaction 的每个值的频率,并为不同的值着色 类。
library(ggplot2)
ggplot(your_data, aes(x = JobSatisfaction, fill = Class)) %>%
geom_bar()
您可以使用 geom_bar()
的 position
参数作为 described here。
我有一个包含 2 个特征的数据框,第一个是类 'Yes' 或 'No',第二个是“JobSatisfaction”。我想画这样的东西。
https://i.stack.imgur.com/oWzV1.png
我在这里计算变量 JobSatisfaction 的每个值的频率,并为不同的值着色 类。
library(ggplot2)
ggplot(your_data, aes(x = JobSatisfaction, fill = Class)) %>%
geom_bar()
您可以使用 geom_bar()
的 position
参数作为 described here。