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

相关推荐
q5673152321 小时前
R语言初学者爬虫简单模板
开发语言·爬虫·r语言·iphone
shootero@126.com2 天前
R语言开发记录,二(创建R包)
r语言
shootero@126.com2 天前
R语言开发记录,一
开发语言·r语言
旷世奇才李先生2 天前
R 语言安装使用教程
开发语言·r语言
十三画者13 天前
【科研绘图系列】R语言绘制circos图形(circos plot)
数据挖掘·数据分析·r语言·数据可视化
Morpheon14 天前
使用 R 处理图像
开发语言·计算机视觉·r语言
WW、forever15 天前
服务器手动安装并编译R环境库包:PROJ→RGDAL
运维·服务器·r语言
WW、forever15 天前
【服务器R环境架构】基于 micromamba下载 R 库包
运维·服务器·r语言
Jet450518 天前
第100+42步 ChatGPT学习:R语言实现阈值调整
开发语言·学习·chatgpt·r语言
Smiling63918 天前
【R】基于R实现贝叶斯分析(一)
r语言·贝叶斯分析·bayes