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

相关推荐
dongf20192 天前
R 语言 Apriori 关联规则算法
数据分析·r语言·关联规则
dongf20192 天前
R语言决策树剪枝----泰坦尼克数据集
决策树·r语言·剪枝
dongf20192 天前
R语言分类决策数算法----iris数据集
分类·数据分析·r语言
dongf20192 天前
R语言决策树----mtcars数据集
决策树·r语言
稷下元歌2 天前
七天学会plc加机器视觉之AI 接入 外设模块开发全详细操作文档(全程配套视频按文档实操)
python·sql·qt·贪心算法·r语言·wpf·时序数据库
dongf20192 天前
R 语言随机森林算法
算法·随机森林·r语言
dongf20193 天前
R语言KKNN算法
开发语言·数据分析·r语言
dongf20193 天前
R语言KNN算法
算法·数据分析·r语言
dongf20193 天前
R语言线性回归
数据分析·r语言·线性回归
天青色等烟雨..4 天前
AI赋能R-Meta分析核心技术:从热点挖掘到高级模型、助力高效科研与论文发表
开发语言·人工智能·r语言