繁体   English   中英

在 R 中可视化汇总统计

[英]visualise summary statistics in R

如何根据此数据摘要在 R 中创建饼图和条形图:

gender        race.ethnicity    parental.level.of.education
female:518    group A: 89       associate's degree:222  
male  :482    group B:190       bachelor's degree :118  
              group C:319       high school       :196 
              group D:262       master's degree   : 59
              group E:140       some college      :226  
                                some high school  :179       

尝试:

gender <- c(518, 482)
names(gender) <- c("male", "female")
pie(gender, names(gender))
barplot(gender)

与您的其他类别相同,例如

groups <- c(89, 190, 319, 262, 140)
names(groups) <- c("A", "B", "C", "D", "E")
pie(groups, names(groups))
barplot(groups)

返回:

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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