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

相关推荐
Q一件事15 小时前
R语言中的图片布局设置
开发语言·r语言
生信大表哥2 天前
生物信息分析:Singularity容器技术深度解析与实战指南
数据库·r语言·rstudio·生信入门·数信院生信服务器
Tiger Z2 天前
《R for Data Science (2e)》免费中文翻译 (第14章) --- Strings(1)
数据分析·r语言·数据科学·免费书籍
生信大表哥2 天前
Claude Code / Gemini CLI / Codex CLI 安装大全(Linux 服务器版)
linux·python·ai·r语言·数信院生信服务器
diegoXie4 天前
PCRE Lookaround (零宽断言)总结(R & Python 通用)
开发语言·python·r语言
itwangyang5204 天前
在 GitHub 上生成和配置个人访问令牌(PAT),并将其用于 R 环境中的凭证管理和包安装。
开发语言·r语言·github
Biomamba生信基地6 天前
ggplot图片主题 复用与保存
r语言·ggplot2
毒鸡蛋6 天前
绘制火山图 R、python
开发语言·python·r语言
青春不败 177-3266-05207 天前
R-Meta分析核心技术:从热点挖掘到高级模型、助力高效科研与论文发表
人工智能·r语言·生态学·meta分析·统计学·环境科学·农业科学
图灵信徒11 天前
R语言第七章线性回归模型
数据挖掘·数据分析·r语言·线性回归