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

相关推荐
亚图跨际8 小时前
MATLAB和R及Python伪时间分析
python·matlab·r语言·伪时间分析
Beekeeper&&P...1 天前
spring中r类是什么
spring·r语言
编码小袁2 天前
深入探究R语言中的机器学习应用——从基础到实战
开发语言·机器学习·r语言
亚图跨际4 天前
R和MATLAB及Python混合效应模型
python·matlab·r语言·混合效应模型
WangYan20224 天前
R语言生物群落(生态)数据统计分析与绘图丨tidyverse数据清洗、多元统计分析、随机森林、回归及混合效应模型、结构方程模型等
r语言·生态·数据统计分析·生物群落
ldinvicible5 天前
stm32mp2 RMII phy调试总结
stm32·macos·r语言
Promising_GEO5 天前
R语言实战——一些批量对地理数据进行操作的方法
开发语言·r语言
亚图跨际5 天前
MATLAB和R及Python亚群差异表达分析
python·matlab·r语言·生物学·亚群差异表达
亚图跨际6 天前
MATLAB和Python及R聚类和亚群识别
python·matlab·r语言·聚类·生物学·亚群
十三画者6 天前
100+SCI科研绘图系列教程(R和python)
python·r语言·数据可视化