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

相关推荐
statistican_ABin1 天前
中国宠物经济发展分析报告——基于R语言的2018-2024年宠物市场多维度分析
开发语言·r语言·宠物
统计学小王子1 天前
数学建模国赛倒计时 3 天 ——《统计模型精讲(分位数回归R语言实现二)》
数学建模·回归·r语言
统计学小王子2 天前
数学建模国赛倒计时4天——《统计模型精讲(混合效应模型R语言实现)》
开发语言·数学建模·r语言
生态学者3 天前
香港理工大学Nature Communications:沿海塑料际古菌组特征及生态影响
大数据·人工智能·算法·r语言·微信公众平台
统计学小王子4 天前
数学建模国赛倒计时6天——《软件工具(R语言精讲)》
开发语言·数学建模·r语言
statistican_ABin5 天前
全球教育水平提升预测分析报告——基于R语言随机森林回归模型的全球40国1960-2020年教育水平预测研究
随机森林·回归·r语言
典典分享指南7 天前
用飞书多维表格搭建内容管理看板
java·python·r语言·composer·symfony
2601_962070239 天前
差异基因富集分析(R语言——GO&KEGG&GSEA)
开发语言·golang·r语言
统计学小王子10 天前
R语言入门——ggplot2图例增加公式
开发语言·r语言
统计学小王子11 天前
R语言入门——相关性热图(建模常用二)
r语言·可视化·相关性分析