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

相关推荐
全栈开发圈12 小时前
干货分享|R语言聚类分析1
开发语言·r语言
AI科技星4 天前
空间光速螺旋动力学:统一质量、引力、电磁与时空本源的公理化理论与全现象验证
c语言·开发语言·opencv·算法·r语言
zhangfeng11337 天前
提示 R for Windows front-end 怎么被防火墙 阻止了 Rscript.exe` 和 `R.exe`区别
windows·r语言·php
全栈开发圈7 天前
新书速览|R语言医学数据分析与可视化
开发语言·数据分析·r语言
木与长清8 天前
人鼠同源基因离线转换
数据库·矩阵·数据分析·r语言
HP-Patience8 天前
【Rmarkdown】快速入门
r语言
HP-Patience8 天前
【Data Mining】01抽样技术
人工智能·数据挖掘·r语言
lihihi9 天前
P1650 [ICPC 2004 Shanghai R] 田忌赛马(同洛谷2587)
开发语言·算法·r语言
请叫我大虾9 天前
数据结构与算法-分裂问题,将数字分成0或1,求l到r之间有多少个1.
java·算法·r语言
MOON404☾9 天前
R语言EDA学习笔记
笔记·学习·数据分析·r语言·eda