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

相关推荐
zm-v-159304339863 小时前
解锁生命周期评价密码:OpenLCA、GREET 与 R 语言的融合应用
r语言·生命周期
生信大杂烩3 小时前
R语言绘图 | 渐变火山图
数据分析·r语言
KY_chenzhao2 天前
用R语言+随机森林玩转遥感空间预测-基于R语言机器学习遥感数据处理与模型空间预测技术及实际项目案例分析
随机森林·机器学习·r语言·生态·遥感·空间预测
没有梦想的咸鱼185-1037-16632 天前
【生命周期分析(Life Cycle Assessment: LCA)】基于OpenLCA、GREET、R语言的生命周期评价方法、模型构建及典型案例应用
数据分析·r语言
没有梦想的咸鱼185-1037-16633 天前
全球森林数据如何分析?基于R语言森林生态系统结构、功能与稳定性分析与可视化
开发语言·随机森林·数据分析·r语言
Tiger Z3 天前
R 语言科研绘图 --- 桑基图-汇总
开发语言·r语言·贴图
Expecto05 天前
因子分析——数学原理及R语言代码
算法·r语言·统计学·多元统计分析
人类群星闪耀时5 天前
R语言数据挖掘:从“挖井”到“淘金”
开发语言·数据挖掘·r语言
Jet45057 天前
第100+40步 ChatGPT学习:R语言实现多轮建模
学习·chatgpt·r语言·多轮建模
Tiger Z7 天前
R 语言科研绘图第 45 期 --- 桑基图-和弦
开发语言·r语言·贴图