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

相关推荐
关关钧1 天前
【R语言】聚类分析
开发语言·r语言
清同趣科研2 天前
扩增子分析|基于R包ggClusterNet包进行生态网络分析—十种可视化布局包括igraph,Gephi和maptree
开发语言·r语言
关关钧3 天前
【R语言】回归分析
开发语言·回归·r语言
Tiger Z4 天前
R 语言科研绘图第 24 期 --- 直方图-高亮
开发语言·程序人生·r语言·贴图
Biomamba生信基地5 天前
R语言学习计划启动
学习·r语言·生信
珏世佳人5 天前
GBD研究——美国州级地图(附资源)
r语言
yaoxin5211235 天前
第二十二章 P - R 开头的术语
linux·运维·r语言
qwy7152292581636 天前
8-R列表
windows·python·r语言
宠物与不尤编程7 天前
Python与R机器学习(1)支持向量机
python·机器学习·支持向量机·r语言
关关钧8 天前
【R语言】t检验
开发语言·r语言