[R] compare the sum, and report with if{}else if{}

You may need to compare the frequency of inquiries about grade distribution and teaching style in the GE_survey dataset. Assuming you have variables in your dataset that represent these inquiries (let's call them Q_grade_distribution and Q_teaching_style for this example), you can use the sum() function to count the number of "Yes" responses for each inquiry and then compare them. Here's how you might do it:

R 复制代码
# Count the number of inquiries about grade distribution
inquiries_grade_distribution <- sum(GE_survey$Q_grade_distribution == "Yes", na.rm = TRUE)

# Count the number of inquiries about teaching style
inquiries_teaching_style <- sum(GE_survey$Q_teaching_style == "Yes", na.rm = TRUE)

# Compare the inquiries
if (inquiries_grade_distribution > inquiries_teaching_style) {
    print("Students are more likely to inquire about grade distribution.")
} else if (inquiries_grade_distribution < inquiries_teaching_style) {
    print("Students are more likely to inquire about teaching style.")
} else {
    print("Students are equally likely to inquire about grade distribution and teaching style.")
}

In this code, Q_grade_distribution and Q_teaching_style should be replaced with the actual variable names in your GE_survey dataset that represent the inquiries about grade distribution and teaching style, respectively. The sum() function counts the number of "Yes" responses for each inquiry, and the if statement compares the counts to determine which inquiry is more common.

相关推荐
czliutz2 天前
R语言gm玩音乐示例代码Rmarkdown
开发语言·r语言
LASDAaaa12312 天前
【计算机视觉】基于Mask R-CNN的自动扶梯缺陷检测方法实现
计算机视觉·r语言·cnn
没有梦想的咸鱼185-1037-16633 天前
AI大模型支持下的:R-Meta分析核心技术:从热点挖掘到高级模型、助力高效科研与论文发表
开发语言·人工智能·机器学习·chatgpt·数据分析·r语言·ai写作
2501_941333103 天前
表格结构识别与内容解析——基于Cascade R-CNN的表格行、列、单元格自动检测与分类_1
分类·r语言·cnn
云州牧3 天前
Mastering Shiny 08 User feedback
r语言
淮北4943 天前
科研绘图工具R语言
开发语言·r语言
余醉 | dtminer4 天前
R语言常见新手问题
开发语言·r语言
佳哥的技术分享5 天前
Function<T, R> 中 apply,compose, andThen 方法总结
java·学习·r语言
2501_942191776 天前
纺织品微观缺陷检测与分类:基于Faster R-CNN的改进模型实现与性能优化_1
分类·r语言·cnn
TDengine (老段)6 天前
TDengine R 语言连接器进阶指南
大数据·开发语言·数据库·r语言·时序数据库·tdengine·涛思数据