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

相关推荐
雁迟14 小时前
第十三章:R 读取 txt、csv 表格数据
r语言
Biomamba生信基地18 小时前
R语言scRNA-seq去RNA污染手册
r语言·单细胞测序·scrna-seq
Omics Pro19 小时前
全流程可重复!R语言脂质组学:原始数据→功能解析
开发语言·人工智能·深度学习·语言模型·r语言·excel·知识图谱
雁迟1 天前
第八章:矩阵与数组操作
线性代数·矩阵·r语言
雁迟2 天前
第六章:for 循环与 while 循环语句
开发语言·r语言
雁迟2 天前
第七章:R 向量用法(最核心数据结构)
开发语言·数据结构·r语言
雁迟2 天前
第九章:列表 List 数据类型
数据结构·r语言
雁迟2 天前
第十章:数据框 DataFrame(数据分析主力)
数据挖掘·数据分析·r语言
雁迟2 天前
第五章:条件判断与分支语句
开发语言·r语言
陳土2 天前
R语言jiebaR包使用摘要
开发语言·r语言