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

相关推荐
知识分享小能手6 小时前
R语言入门学习教程,从入门到精通,R语言日期和时间序列(6)
开发语言·学习·r语言
QH_ShareHub2 天前
从 R 到 Python:数据科学生态的“双语”对照手册
开发语言·python·r语言
Yolo566Q2 天前
环境土壤物理模型HYDRUS1D/2D/3D实践技术应用系统性学习
大数据·开发语言·gpt·学习·arcgis·r语言
知识分享小能手2 天前
R语言入门学习教程,从入门到精通,R语言流程控制语句(5)
开发语言·学习·r语言
知识分享小能手3 天前
R语言入门学习教程,从入门到精通,R语言数据结构(4)
数据结构·学习·r语言
胖哥真不错4 天前
R实现负二项回归模型项目实战
回归·r语言·毕业设计·项目实战·负二项回归模型
知识分享小能手4 天前
R语言入门学习教程,从入门到精通,R语言入门(3)
开发语言·学习·r语言
赵钰老师5 天前
R语言在生态环境领域中的应用
开发语言·数据分析·r语言
知识分享小能手5 天前
R语言入门学习教程,从入门到精通,集成开发环境RStudio(2)
开发语言·学习·r语言
Biomamba生信基地5 天前
拷贝数变异分析的python实现及R语言对比
python·r语言·生物信息学·单细胞测序