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

相关推荐
Tiger Z11 小时前
《R for Data Science (2e)》免费中文翻译 (第12章) --- Logical vectors(1)
数据分析·r语言·数据科学·免费书籍
AI纪元故事会1 天前
《目标检测全解析:从R-CNN到DETR,六大经典模型深度对比与实战指南》
人工智能·yolo·目标检测·r语言·cnn
小八四爱吃甜食3 天前
【R语言】构建GO、KEGG相关不同物种的R包
开发语言·golang·r语言
梦想的初衷~3 天前
生命周期评价(LCA):理论、方法与工具、典型案例全解析
r语言·农业·林业·环境科学·地理·气候变化·生命周期评价
asyxchenchong8883 天前
OpenLCA、GREET、R语言的生命周期评价方法、模型构建
开发语言·r语言
没有梦想的咸鱼185-1037-16633 天前
【生命周期评价(LCA)】基于OpenLCA、GREET、R语言的生命周期评价方法、模型构建
开发语言·数据分析·r语言
zhangfeng11334 天前
亲测有效的mem 流行病预测,时间序列预测,r语言做移动流行区间法,MEM流行病阈值设置指南
开发语言·r语言·生物信息
普通网友6 天前
Golang笔记——Interface类型
r语言
maizeman1266 天前
用R语言生成指定品种与对照的一元回归直线(含置信区间)
开发语言·回归·r语言·置信区间·品种测试
兮兮能吃能睡7 天前
R语言模型分析(一)(1)
开发语言·r语言