grades = read.csv("~/Downloads/a.csv",header = TRUE)
grades <- grades[-nrow(grades),]
library(tidyr)
grades <- separate(grades, Section, c("Lecture", "Lab"), sep = " UMNRO CHEM 1331 ")
grades$Lab = sub("\\(Fall 2022\\) and ","",grades$Lab)

library(ggplot2)
library(ggpubr)
library(psych)

plotGGbox = function(df,myx,myy,mytitle,myylab){
  df = df[complete.cases(df[[myy]]),]
  maxy = max(df[[myy]])
  ggboxplot(df, x = myx, y = myy,  
            title = mytitle,
            color = myx, add = "jitter", legend="none",ylab = myylab) + rotate_x_text(angle = 45) +  
    geom_hline( yintercept = mean(df[[myy]]), linetype = 2) + 
    stat_compare_means(method = "anova", label.y = maxy*1.10) +
    coord_cartesian(ylim = c(0, maxy*1.2)) + 
    stat_compare_means(label = "p.format", size=2.5, method = "t.test", ref.group = ".all.",label.y = maxy*1.05)
}
getAnova = function(df,myx,myy,mytitle,myylab){
  #get anova
  a<- TukeyHSD( aov(df[[myy]] ~ df[[myx]])) 
  b<-as.data.frame(a$`df[[myx]]`[,4])
  colnames(b) = c("Testing statistical significance: p-values")
  print(knitr::kable(b, caption = paste("Anova: ",mytitle)))
}
plotAndTable = function(df,myx,myy,mytitle,myylab){
  print(plotGGbox(df,myx,myy,mytitle,myylab))
  table = describeBy(df[[myy]],df[[myx]],mat=TRUE,digits = 2)
  print(knitr::kable(table[,c(2,4,5,6,7,10,11,12)],caption=paste("Statistics of ",myylab)))
  getAnova(df,myx,myy,mytitle,myylab)
}

1 Lecture comparison

1.1 Open ended

#5: Rachel
#6: Tim
#7: Tim
#8: Olivia
#9: Rachel
#10: Victoria
#11: Victoria
#12: Victoria
#14: Rachel
#15: Tim
plotAndTable(grades,"Lecture","Open.Ended.Semester.Exams.Current.Score","Lecture section","OpenEnded exam score")

Statistics of OpenEnded exam score
group1 n mean sd median min max range
X11 001 55 63.03 22.04 64 19 100 81
X12 002 53 64.53 21.29 66 17 104 87
X13 003 55 71.63 19.24 73 18 104 86
X14 004 47 62.08 21.53 58 8 102 94
Anova: Lecture section
Testing statistical significance: p-values
002-001 0.9824884
003-001 0.1423058
004-001 0.9958664
003-002 0.2985012
004-002 0.9374981
004-003 0.1044592

1.2 Milestones

plotAndTable(grades,"Lecture","Milestones.Current.Score","Lecture section","Milestone average score")

Statistics of Milestone average score
group1 n mean sd median min max range
X11 001 55 92.36 16.75 100 26.67 100 73.33
X12 002 53 90.94 17.15 100 33.33 100 66.67
X13 003 55 94.91 16.13 100 0.00 100 100.00
X14 004 47 94.18 14.22 100 33.33 100 66.67
Anova: Lecture section
Testing statistical significance: p-values
002-001 0.9682722
003-001 0.8420287
004-001 0.9416842
003-002 0.5798265
004-002 0.7489376
004-003 0.9959279

1.3 Homework

plotAndTable(grades,"Lecture","Homework.Current.Score","Lecture section","Homework average score")

Statistics of Homework average score
group1 n mean sd median min max range
X11 001 55 89.04 10.24 90.73 33.87 99.83 65.96
X12 002 53 87.75 10.50 91.07 44.02 99.72 55.70
X13 003 55 92.11 6.60 94.35 62.84 100.00 37.16
X14 004 47 88.19 11.74 91.38 32.43 99.83 67.40
Anova: Lecture section
Testing statistical significance: p-values
002-001 0.9059601
003-001 0.3644425
004-001 0.9728609
003-002 0.1035661
004-002 0.9961713
004-003 0.1926688

2 Lab sections

2.1 Lab notebook

plotAndTable(grades,"Lab","Lab.Notebook.Pages.Current.Score","Lab section","Lab notebook")

Statistics of Lab notebook
group1 n mean sd median min max range
X11 005 23 86.32 14.43 89.50 41.00 100.00 59.00
X12 006 23 91.73 7.34 92.51 72.80 100.00 27.20
X13 007 19 92.98 6.13 95.02 79.70 99.18 19.48
X14 008 20 95.54 4.85 96.39 78.07 100.00 21.93
X15 009 20 90.03 8.05 91.87 63.33 98.33 35.00
X16 010 22 93.28 10.41 96.94 52.50 100.00 47.50
X17 011 21 97.09 3.53 97.78 87.78 100.00 12.22
X18 012 17 91.79 5.20 93.89 83.75 99.44 15.69
X19 014 22 87.67 10.74 90.70 52.78 96.67 43.89
X110 015 23 94.45 3.67 94.73 81.67 100.00 18.33
Anova: Lab section
Testing statistical significance: p-values
006-005 0.4536059
007-005 0.2305226
008-005 0.0129087
009-005 0.9057424
010-005 0.1401342
011-005 0.0011084
012-005 0.5590945
014-005 0.9999380
015-005 0.0352948
007-006 0.9999761
008-006 0.8907735
009-006 0.9996418
010-006 0.9997990
011-006 0.5040820
012-006 1.0000000
014-006 0.8258426
015-006 0.9834695
008-007 0.9939773
009-007 0.9832442
010-007 1.0000000
011-007 0.8649227
012-007 0.9999915
014-007 0.5691046
015-007 0.9999097
009-008 0.5305484
010-008 0.9968779
011-008 0.9998650
012-008 0.9348803
014-008 0.0721344
015-008 0.9999913
010-009 0.9597358
011-009 0.1728119
012-009 0.9997502
014-009 0.9956338
015-009 0.7718273
011-010 0.8897768
012-010 0.9999239
014-010 0.4317177
015-010 0.9999819
012-011 0.6306731
014-011 0.0095827
015-011 0.9882963
014-012 0.8756025
015-012 0.9919737
015-014 0.1662547

2.2 Lab reporting

plotAndTable(grades,"Lab","Lab.Reporting.Current.Score","Lab section","Lab report")

Statistics of Lab report
group1 n mean sd median min max range
X11 005 23 84.95 11.78 88.58 57.62 100.00 42.38
X12 006 23 81.00 10.48 80.83 57.58 94.67 37.09
X13 007 19 83.24 10.18 83.92 61.67 96.67 35.00
X14 008 20 88.07 5.61 90.08 75.69 97.61 21.92
X15 009 20 87.30 6.43 88.53 72.58 95.67 23.09
X16 010 22 87.43 12.13 90.70 45.55 99.26 53.71
X17 011 21 91.24 3.82 91.55 84.45 97.78 13.33
X18 012 17 84.82 11.77 87.71 57.90 95.21 37.31
X19 014 22 84.86 8.81 87.78 57.63 95.34 37.71
X110 015 23 86.73 7.19 89.08 64.26 96.30 32.04
Anova: Lab section
Testing statistical significance: p-values
006-005 0.9099363
007-005 0.9998653
008-005 0.9840132
009-005 0.9979802
010-005 0.9963067
011-005 0.4228557
012-005 1.0000000
014-005 1.0000000
015-005 0.9997099
007-006 0.9987599
008-006 0.2749816
009-006 0.4397663
010-006 0.3721648
011-006 0.0112864
012-006 0.9544198
014-006 0.9260199
015-006 0.5279618
008-007 0.8326384
009-007 0.9345612
010-007 0.9104099
011-007 0.1677098
012-007 0.9999628
014-007 0.9999215
015-007 0.9688430
009-008 0.9999999
010-008 1.0000000
011-008 0.9842417
012-008 0.9875187
014-008 0.9819038
015-008 0.9999813
010-009 1.0000000
011-009 0.9366075
012-009 0.9983069
014-009 0.9975104
015-009 1.0000000
011-010 0.9402008
012-010 0.9970368
014-010 0.9955552
015-010 0.9999999
012-011 0.5091618
014-011 0.4176684
015-011 0.8385012
014-012 1.0000000
015-012 0.9997358
015-014 0.9996039

2.3 Prelab

plotAndTable(grades,"Lab","Pre.Lab.Assignments.Current.Score","Lab section","Prelab")

Statistics of Prelab
group1 n mean sd median min max range
X11 005 23 98.79 1.76 99.54 93.06 100 6.94
X12 006 23 95.86 4.38 97.22 84.69 100 15.31
X13 007 19 98.47 1.37 98.98 95.75 100 4.25
X14 008 20 98.75 1.10 98.76 96.14 100 3.86
X15 009 20 97.59 3.36 98.96 89.12 100 10.88
X16 010 22 97.91 2.75 98.76 89.46 100 10.54
X17 011 21 98.95 1.43 99.54 95.52 100 4.48
X18 012 17 97.92 3.51 99.23 88.10 100 11.90
X19 014 22 97.57 2.64 98.72 91.50 100 8.50
X110 015 23 97.63 3.07 98.30 87.41 100 12.59
Anova: Lab section
Testing statistical significance: p-values
006-005 0.0139655
007-005 0.9999973
008-005 1.0000000
009-005 0.9186690
010-005 0.9875709
011-005 1.0000000
012-005 0.9925976
014-005 0.8964210
015-005 0.9192423
007-006 0.0749833
008-006 0.0240066
009-006 0.5601627
010-006 0.2725438
011-006 0.0094322
012-006 0.3699165
014-006 0.5423480
015-006 0.4694283
008-007 0.9999992
009-007 0.9923585
010-007 0.9997575
011-007 0.9999224
012-007 0.9998614
014-007 0.9892591
015-007 0.9933321
009-008 0.9432227
010-008 0.9926281
011-008 1.0000000
012-008 0.9955369
014-008 0.9271602
015-008 0.9448274
010-009 0.9999970
011-009 0.8544051
012-009 0.9999982
014-009 1.0000000
015-009 1.0000000
011-010 0.9657294
012-010 1.0000000
014-010 0.9999935
015-010 0.9999989
012-011 0.9782591
014-011 0.8224565
015-011 0.8530791
014-012 0.9999962
015-012 0.9999993
015-014 1.0000000