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

相关推荐
烟锁池塘柳01 天前
【R语言】R 语言中 gsub 与正则表达式详解(含 POSIX 与 Perl 风格实例)
正则表达式·r语言·perl
梦想的初衷~2 天前
“R+遥感”的水环境综合评价方法实践技术应用
r语言·水环境·水文
天意生信云3 天前
生信分析自学攻略 | R软件和Rstudio的安装
经验分享·r语言
TS的美梦3 天前
【1:1复刻R版】python版火山图函数一键出图
开发语言·python·r语言·scanpy·火山图
nonono3 天前
深度学习——R-CNN及其变体
深度学习·r语言·cnn
烟锁池塘柳04 天前
【R语言】R 语言中打印含有双引号的字符串时会出现 “\” 的原因解析
r语言
全栈开发圈8 天前
干货分享|如何从0到1掌握R语言数据分析
开发语言·数据分析·r语言
小杜的生信筆記10 天前
基于R语言,“上百种机器学习模型”学习教程 | Mime包
开发语言·学习·机器学习·r语言·sci
在打豆豆的小潘学长11 天前
【R语言】多样本单细胞分析_SCTransform+Harmony方案(2)
开发语言·r语言
TS的美梦11 天前
ROGUE: 【张院士团队R包】一种基于熵的用于评估单细胞群体纯度的度量标准
开发语言·r语言