[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.

相关推荐
生态学者4 小时前
香港理工大学Nature Communications:沿海塑料际古菌组特征及生态影响
大数据·人工智能·算法·r语言·微信公众平台
统计学小王子1 天前
数学建模国赛倒计时6天——《软件工具(R语言精讲)》
开发语言·数学建模·r语言
statistican_ABin2 天前
全球教育水平提升预测分析报告——基于R语言随机森林回归模型的全球40国1960-2020年教育水平预测研究
随机森林·回归·r语言
典典分享指南4 天前
用飞书多维表格搭建内容管理看板
java·python·r语言·composer·symfony
2601_962070236 天前
差异基因富集分析(R语言——GO&KEGG&GSEA)
开发语言·golang·r语言
统计学小王子7 天前
R语言入门——ggplot2图例增加公式
开发语言·r语言
统计学小王子8 天前
R语言入门——相关性热图(建模常用二)
r语言·可视化·相关性分析
知识分享小能手10 天前
概理论与数理统计学习教程,从入门到精通,在数理统计中应用R软件(22)
开发语言·学习·r语言
知识分享小能手10 天前
概理论与数理统计学习教程,从入门到精通,在数理统计中应用R软件(21)
开发语言·学习·r语言
asyxchenchong88816 天前
R语言混合效应(多水平/层次/嵌套)模型及贝叶斯实现技术应用
开发语言·r语言