-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestanalyzeR app.R
764 lines (702 loc) · 25.9 KB
/
testanalyzeR app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
#########LIBRARIES#######################################################
library(tidyverse)
library(dplyr)
library(tidyr)
library(psych)
library(openxlsx)
library(DT)
library(stringr)
library(mirt)
library(psychometric)
library(ltm)
library(corrplot)
library(CTT)
library(ShinyItemAnalysis)
library(bslib)
#######UTILS###########################################################################
tema <- bs_theme( bg= "white",fg = "navy ", primary = "tomato",
base_font = font_google("Space Mono"),
code_font = font_google("Space Mono")
)
#GÜÇLÜK AYIRTEDİCİLİK FONKSİYONLARI:
labelDifficulties<-function (itemDifficulties){
difficultycommemnt <- c()
for (difficulty in 1:length(itemDifficulties)){
if(itemDifficulties[difficulty] <= 0.2){difficultycommemnt[difficulty]<- "DIFFICULT"
}else if(itemDifficulties[difficulty] > 0.2 & itemDifficulties[difficulty] < 0.8){difficultycommemnt[difficulty]<- " MEDIOCRE"
}else{difficultycommemnt[difficulty]<- " EASY"
}
}
return(difficultycommemnt)
}
percent_al<-function(df){
x<- vector("numeric", length=length(df))
for (i in 1:length(df))
x[i]<-round(df[i]/sum(df),3)
return(x)
}
labelDiscriminations<- function(itemDiscriminations){
discriminationcomment<-c()
for (discrimination in 1:length(itemDiscriminations)) {
if(itemDiscriminations[discrimination] <= 0 | is.na(itemDiscriminations[discrimination] ) ){discriminationcomment[discrimination]<- " DISCARD"
}else if(itemDiscriminations[discrimination] <= 0.2 & itemDiscriminations[discrimination] > 0){ discriminationcomment[discrimination]<- " REVISE"
}else if(itemDiscriminations[discrimination] <= 0.3 & itemDiscriminations[discrimination] > 0.2){ discriminationcomment[discrimination]<- " MEDIUM"
}else if(itemDiscriminations[discrimination] <= 0.4 & itemDiscriminations[discrimination] > 0.3){ discriminationcomment[discrimination]<- " GOOD"
}else if(itemDiscriminations[discrimination] > 0.4){ discriminationcomment[discrimination]<- "VERY GOOD"
}
}
return(discriminationcomment)
}
main_function<- function ( datapath,
a, b, c, d,
x, y, z, w,
requested_output=c(1:7),
p_table=NULL)
#a, b, c, and d are item numbers of possible four parts.
#x, y, z, and w are respectively maximum points of possible four parts.
{
#N of items
part1<-a
if (b != 0){part2<-b}else{part2<-1}
if (c != 0){part3<-c}else{part3<-1}
if (d != 0){part4<-d}else{part4<-1}
#max Converted scores
max_score_part1<-x
if (y != 0){max_score_part2<-y}else{max_score_part2<-1}
if (z != 0){max_score_part3<-z}else{max_score_part3<-1}
if (w != 0){max_score_part4<-w}else{max_score_part4<-1}
part5 <- 1#input$part5
part6 <- 1#input$part6
tbl <- read.delim(datapath, header = FALSE, dec = " ")
data <- str_split_fixed(tbl[, 1], "N", 2)
data <- as.data.frame(data[,-1])
colnames(data) <- "v1"
#conversion of turkish letters such as ü or ş etc.:
data$v1 <- gsub('<dd>', 'I', data$v1)
data$v1 <- gsub('<d6>', 'O', data$v1)
data$v1 <- gsub('<de>', 'S', data$v1)
data$v1 <- gsub('<d0>', 'G', data$v1)
data$v1 <- gsub('<c7>', 'C', data$v1)
data$v1 <- gsub('<dc>', 'U', data$v1)
#(custom) N of chars in each section on the optical form
data <- data %>%
separate(v1, into = c("st_id", "colm"), sep = 15)
data <- data %>%
separate(colm, into = c("part_1", "colm"), sep = 50)
data <- data %>%
separate(colm, into = c("part_2", "colm"), sep = 50)
data <- data %>%
separate(colm, into = c("part_3", "colm"), sep = 50)
data <- data %>%
separate(colm, into = c("part_4", "colm"), sep = 50)
data <- data %>%
separate(colm, into = c("part_5", "colm"), sep = 50)
data <- data %>%
separate(colm, into = c("part_6", "colm"), sep = 50)
data <- data %>%
separate(colm, into = c("st_name", "colm"), sep = 14)
data <- data %>%
separate(colm, into = c("st_surname", "colm"), sep = 14)
data <- data %>%
separate(colm, into = c("section", "colm"), sep = 6)
data <- data %>%
separate(colm, into = c("room_desk_id"), sep = 4)
data <- data %>%
separate(part_1, into = c("part_1"), sep = part1)
data <- data %>%
separate(part_2, into = c("part_2"), sep = part2)
data <- data %>%
separate(part_3, into = c("part_3"), sep = part3)
data <- data %>%
separate(part_4, into = c("part_4"), sep = part4)
data <- data %>%
separate(part_5, into = c("part_5"), sep = part5)
data <- data %>%
separate(part_6, into = c("part_6"), sep = part6)
#section adı ile burada ilgilen:
data$section <- gsub(" ", "", data$section)
#response set şekil ver:
data$part_1 <- str_split_fixed(data$part_1, "", part1)
data$part_2 <- str_split_fixed(data$part_2, "", part2)
data$part_3 <- str_split_fixed(data$part_3, "", part3)
data$part_4 <- str_split_fixed(data$part_4, "", part4)
data$part_5 <- str_split_fixed(data$part_5, "", part5)
data$part_6 <- str_split_fixed(data$part_6, "", part6)
if(requested_output == 1){ data<-data }else{
AK<-data[1,]
data<-subset(data, data$st_id != " "
& data$st_name != " "
& data$st_surname != " " )
data<-rbind(AK, data)
row.names(data)<- 1:nrow(data)
}
if (part4 == 1 & part3 != 1) {
respo <- as.data.frame(cbind(data$part_1[, 1:part1],
data$part_2[, 1:part2],
data$part_3[, 1:part3]))
}else if(part3 == 1 & part4 == 1){
respo <- as.data.frame(cbind(data$part_1[, 1:part1],
data$part_2[, 1:part2]))
}else{
respo <- as.data.frame(cbind(data$part_1[, 1:part1],
data$part_2[, 1:part2],
data$part_3[, 1:part3],
data$part_4[, 1:part4]))
}
unscored_respo <- as.matrix(sapply(respo,
function(functiondata)
as.numeric(
gsub("A", 1,
gsub("B", 2,
gsub("C", 3,
gsub("D", 4,
gsub("E", 5, functiondata)
)))
))))
anskey <- as.matrix(unscored_respo[1, 1:ncol(unscored_respo)])
scored_respo <- key2binary(unscored_respo, anskey, score_missing = TRUE)
colnames(scored_respo) <- paste0("item", 1:ncol(scored_respo))
data_for_distractorAnal <- as.matrix(drop_na(as.data.frame(unscored_respo)))
ans_for_distractorAnal <- as.character(anskey)
results <- as.data.frame(scored_respo)
if (part4 == 1 & part3 != 1) {
results$total_part_1 <- rowSums(results[, 1:part1])
results$total_part_2 <- rowSums(results[, (part1 + 1):(part1 + part2)])
results$total_part_3 <- rowSums(results[, (1 + part1 + part2):(part1 + part2 + part3)])
results$conv_part_1 <- (results$total_part_1 * max_score_part1) / part1
results$conv_part_2 <- (results$total_part_2 * max_score_part2) / part2
results$conv_part_3 <- (results$total_part_3 * max_score_part3) / part3
# requested_output 6: 1/3
sumstats <- rbind(
summary(results$conv_part_1),
summary(results$conv_part_2),
summary(results$conv_part_3)
)
rownames(sumstats) <- c("Part-1:", "Part-2:", "Part-3:")
}else if(part3 == 1 & part4 == 1){
results$total_part_1 <- rowSums(results[, 1:part1])
results$total_part_2 <- rowSums(results[, (part1 + 1):(part1 + part2)])
results$conv_part_1 <- (results$total_part_1 * max_score_part1) / part1
results$conv_part_2 <- (results$total_part_2 * max_score_part2) / part2
# requested_output 6: 2/3
sumstats <- rbind(
summary(results$conv_part_1),
summary(results$conv_part_2)
)
rownames(sumstats) <- c("Part-1:", "Part-2:")
}else{
results$total_part_1 <- rowSums(results[, 1:part1])
results$total_part_2 <- rowSums(results[, (part1 + 1):(part1 + part2)])
results$total_part_3 <- rowSums(results[, (1 + part1 + part2):(part1 + part2 + part3)])
results$total_part_4 <- rowSums(results[, (1 + part1 + part2 + part3):(part1 + part2 + part3 + part4)])
results$conv_part_1 <- (results$total_part_1 * max_score_part1) / part1
results$conv_part_2 <- (results$total_part_2 * max_score_part2) / part2
results$conv_part_3 <- (results$total_part_3 * max_score_part3) / part3
results$conv_part_4 <- (results$total_part_4 * max_score_part4) / part4
# requested_output 6: 3/3
sumstats <- rbind(
summary(results$conv_part_1),
summary(results$conv_part_2),
summary(results$conv_part_3),
summary(results$conv_part_4)
)
rownames(sumstats) <- c("Part-1:", "Part-2:", "Part-3:", "Part-4:")
}
#requested_output 1 :EXAM TAKER REPORT:
exam_results <- as.data.frame(cbind(
data$st_id,
data$st_name,
data$st_surname,
data$section,
respo,
results
))
if (part4 == 1 & part3 != 1) {
st_resp_itemnames <-
paste0("st_resp@item", 1:(part1 + part2 + part3 ))
dicho_itemnames <- paste0("item", 1:(part1 + part2 + part3 ))
colnames(exam_results) <-
c(
"st_id",
"st_name",
"st_fam.name",
"section",
st_resp_itemnames,
dicho_itemnames,
"Truescore@part1",
"Truescore@part2",
"Truescore@part3",
"conv_sco@part1",
"conv_sco@part2",
"conv_sco@part3"
)
}else if(part3 == 1 & part4 == 1){
st_resp_itemnames <-
paste0("st_resp@item", 1:(part1 + part2))
dicho_itemnames <- paste0("item", 1:(part1 + part2))
colnames(exam_results) <-
c(
"st_id",
"st_name",
"st_fam.name",
"section",
st_resp_itemnames,
dicho_itemnames,
"Truescore@part1",
"Truescore@part2",
"conv_sco@part1",
"conv_sco@part2"
)
}else{
st_resp_itemnames <-
paste0("st_resp@item", 1:(part1 + part2 + part3 + part4))
dicho_itemnames <- paste0("item", 1:(part1 + part2 + part3 + part4))
colnames(exam_results) <-
c(
"st_id",
"st_name",
"st_fam.name",
"section",
st_resp_itemnames,
dicho_itemnames,
"Truescore@part1",
"Truescore@part2",
"Truescore@part3",
"Truescore@part4",
"conv_sco@part1",
"conv_sco@part2",
"conv_sco@part3",
"conv_sco@part4"
)
}
#requested_output 2: ITEM LEVEL ANALYSIS:
scored_respo<-scored_respo[ rowSums(scored_respo[,-1]) > 0, ]
#item_stats<- ItemAnalysis(scored_respo)
difficulties<-round(colMeans(scored_respo),2)
discriminations<-round(item.total(scored_respo)$Item.Total,2)
DISC.LABELS<-labelDiscriminations(discriminations)
DIFF.LABELS<-labelDifficulties(difficulties)
item_stats<- cbind(difficulties, discriminations, DIFF.LABELS, DISC.LABELS )
colnames(item_stats)<- c("difficulty index", "discrimination index", "difficulty comment", "discrimination comment")
#requested_output 7:TEST LEVEL ANALYSIS:
mytable<-table( DIFF.LABELS, DISC.LABELS)
....TOTAL<-colSums(mytable)
..PERCENT<-round(percent_al(....TOTAL)*100)
mytable<-rbind(mytable,....TOTAL, ..PERCENT)
#...TOTAL<-rowSums(mytable)
# mytable<-cbind(mytable , ...TOTAL )
#requested_output 3:TEST LEVEL ANALYSIS:
#güvenirlik katsatısı
alpha_index<-cronbach.alpha(scored_respo)
#requested_output 4:OPTION LEVEL ANALYSIS:
if (p_table=="Counts"){p_table<-FALSE } else{ p_table<-TRUE}
option_level_stats <- ShinyItemAnalysis::DistractorAnalysis(data_for_distractorAnal,
ans_for_distractorAnal,
p.table = p_table, num.groups=3)
if(requested_output == 1){ return(exam_results)}
if(requested_output == 2){ return(item_stats)}
if(requested_output == 3){ return(alpha_index)}
if(requested_output == 4){ return(option_level_stats )}
if(requested_output == 5){ return(as.data.frame(scored_respo))}
if(requested_output == 6){ return(as.data.frame(sumstats))}
if(requested_output == 7){ return(mytable)}
}
##########USER INTERFACE################################################################
#shiny::runGitHub("dreamRs/fresh", subdir = "inst/examples/create")
ui <- fluidPage(
theme = tema,
sidebarLayout(
sidebarPanel(
width = 3,
tags$a(href="https://www.etu.edu.tr/en/bolum/department-of-foreign-languages/duyuru/-",
tags$img(src='tobb_etu__logo_tr.png',
align="middle",
height = "49px",
style='padding-top: 1px')),
tags$hr(),
fileInput('file1', 'Upload your .dat file'),
tags$b(
"Please enter the number of items and maximum possible score for each part below."
),
tags$br(),
tags$br(),
tags$p(
tags$b(
"If there are LESS THAN FOUR parts, please enter ZERO for both cells."
)
),
hr(),
splitLayout(
numericInput(
inputId = 'part1',
label = 'Part 1',
value = 10
),
numericInput(
inputId = 'max_score_part1',
label = 'Max:',
value = 100
)
),
splitLayout(
numericInput(
inputId = 'part2',
label = 'Part 2',
value = 10
),
numericInput(
inputId = 'max_score_part2',
label = 'Max:',
value = 100
)
),
splitLayout(
numericInput(
inputId = 'part3',
label = 'Part 3',
value = 10
),
numericInput(
inputId = 'max_score_part3',
label = 'Max:',
value = 100
)
),
splitLayout(
numericInput(
inputId = 'part4',
label = 'Part 4',
value = 10
),
numericInput(
inputId = 'max_score_part4',
label = 'Max:',
value = 100
)
),
hr(),
),
mainPanel(
titlePanel(' Test Analyze-R '),
tags$p(
"This is an application developed specifically for obtaining test scores and for conducting elementary item analysis on test data
which were scanned directly by optical mark recognition machines at TOBB ETÜ-DFL.
With this application, you can easily read .dat files, conduct item analysis, and generate detailed reports
to measure student performance and identify areas of improvement.
This is a reactive application -
meaning; you do not need to click anywhere to get the output.
So, for optimum performance, enter your input into the cells (on the left) before you upload any files.
Then, wait for a few seconds. Reload the page any time you upload a new file.",
tags$b("The only accepted file format is .dat.")),
tags$p("You can download",tags$a(href="https://drive.google.com/file/d/1hVEldl2mKDec1NIcRhTKq00v_zPNp_mJ/view?usp=share_link",
"a sample .dat file"), "in order to try the app (Keep the default input values for the sample)."),
hr(),
tabsetPanel(
tabPanel(
"Student Scores",
hr(),
tags$br(),
dataTableOutput(outputId = 'table.output')
),
tabPanel(
"Test Statistics",
hr(),
tags$br(),
tags$b("DESCRIPTIVE STATISTICS"),
tags$p(
"Descriptive statistics gives us an insight to our test and sample.
We investigate descriptives depending on the data's distribution."
),
tags$b(" RELIABILITY"),
tags$p(
"Cronbach's α is an estimate of the internal consistency of a test.
The α index is between 0 and 1. The higher the better for educational tests."
),
tags$b("VALIDITY"),
tags$p("Test Analyze-R provides two types of output currently:"),
tags$p(tags$b(" Scree Plot ")),
tags$p(
"A scree plot might give us a clue about the factors of the test.
In the screeplot, each dot/triangle located above the red line might indicate a factor.
If there are any items with zero variance (meaning: all students gave the same response to an item),
a scree plot will NOT be calculated. In that case, you might also use a correlation heat map (below) as a validity check."
),
tags$b("Correlation Heat Map"),
tags$p(
"A correlation heat map displays the correlation between item pairs.
The color of circles indicates in which way the items are correlated-
a blue color means possitive correlation and a red color means negative correlation.
The diogonal will always be dark blue. Other than that, we do not want red or dark blue dots.
Instead, LIGHT BLUE DOTS are expected output in this plot."
),
hr(),
verbatimTextOutput(outputId = "summary_stats"),
hr(),
verbatimTextOutput(outputId = "c.alpha"),
hr(),
plotOutput(
outputId = "scree_plot",
width = "100%",
height = "400px"
),
tags$br(),
plotOutput(
outputId = "cor_plot",
width = "100%",
height = "400px"
),
),
tabPanel(
"Item Statistics",
hr(),
tags$br(),
tags$b("ITEM ANALYSIS"),
tags$p(
"Difficulty of an item is simply: N of individuals with correct response / N of total group. That's why it is also called mean of the item."),
tags$p(
"Discrimination of an item, on the other hand, can be calculated with three different methods.
They are listed below and we use the second one in this app."),
tags$p(tags$b("1."), "Correlation between the item and total score."),
tags$p(tags$b("2."), "Correlation between the item and total score withhout the item."),
tags$p(tags$b("3."), "The difference in item score in the upper and lower third of the respondents (Upper-Lower Index, ULI)."),
tags$p("The Difficulty-Discrimination Plot below is a nice visualization of item properties."),
plotOutput( outputId = "DD_plot", width = "100%", height = "400px"),
dataTableOutput(outputId = 'item.anal')
),
tabPanel(
"Distractor Statistics",
hr(),
tags$br(),
tags$b("DISTRACTOR ANALYSIS"),
tags$p(
"In this report, you will see a table for each item.
In the columns, the test takers are divided into three subgroups according to their total scores."),
tags$p(tags$b("Group 1"), "is the test takers with the lowest scores."),
tags$p(tags$b("Group 3"), "is the test takers with the highest scores."),
tags$p("In the rows, you will see numbers referring to options. 1-5 means A-E.
If you don't see an option, it means it is not selected by any test takers."),
radioButtons(inputId = "p_table", label = "Choose to swap:",
choices = c("Counts", "Percentages"), selected = "Counts"),
verbatimTextOutput(outputId = "distractor.anal")
# dataTableOutput(outputId = "distractor.anal")
),
tabPanel(
"Item Writer Report",
hr(),
tags$br(),
verbatimTextOutput(outputId = "commenttable")
# dataTableOutput(outputId = "commenttable")
)
)
)
))
##########SERVER####################################################################
server <- function(input, output) {
options(shiny.sanitize.errors = TRUE)
#exam results:
output$table.output <- renderDataTable({
if (is.null(input$file1)) return(NULL)
exam_results <- main_function(
input$file1$datapath,
input$part1,
input$part2,
input$part3,
input$part4,
input$max_score_part1,
input$max_score_part2,
input$max_score_part3,
input$max_score_part4,
1,
p_table = input$p_table
)
datatable(
data = exam_results,
caption = "First select 'show all rows'. Then click on 'Excel' to download the results. ",
extensions = c('Buttons'),
options = list(
dom = 'Bfrtip',
buttons = c('pageLength', 'excel'),
pagelength = 5,
lengthMenu = list(c(5, 25, 50, 100,-1),
c('5', '25', '50', '100', 'All'))
)
)
})
#scree plot:
output$scree_plot <- renderPlot({
if (is.null(input$file1))
return(NULL)
scored_respo <- main_function(
datapath = input$file1$datapath,
input$part1,
input$part2,
input$part3,
input$part4,
input$max_score_part1,
input$max_score_part2,
input$max_score_part3,
input$max_score_part4,
5,
p_table = input$p_table
)
scree_pl <- fa.parallel(scored_respo, fa = "pc")
})
#correlation matrix:
output$cor_plot <- renderPlot({
if (is.null(input$file1))
return(NULL)
scored_respo <- main_function(
datapath = input$file1$datapath,
input$part1,
input$part2,
input$part3,
input$part4,
input$max_score_part1,
input$max_score_part2,
input$max_score_part3,
input$max_score_part4,
5,
p_table = input$p_table
)
item_cor <- corrplot(round(cor(scored_respo), 1),
method = "circle",
title="Correlations Heat Map",
na.label ="#",
na.label.col = "tomato",
diag=T)
})
#item analysis:
output$item.anal <- renderDataTable({
if (is.null(input$file1))
return(NULL)
item_stats <- main_function(
datapath = input$file1$datapath,
input$part1,
input$part2,
input$part3,
input$part4,
input$max_score_part1,
input$max_score_part2,
input$max_score_part3,
input$max_score_part4,
2,
p_table = input$p_table
)
datatable(
data = item_stats,
caption = "First select 'show all rows'. Then click on 'Excel' to download the results. ",
extensions = c('Buttons'),
options = list(
dom = 'Bfrtip',
buttons = c('pageLength', 'excel'),
pagelength = 5,
lengthMenu = list(c(5, 10, 20, 40, 70,-1),
c('5', '10', '20', '40', '70', 'All'))
)
)
})
#reliability index:
output$c.alpha <- renderPrint({
validate(need(
try(input$file1 != "")
, "A reliability index will appear here when data is uploaded."
))
alpha_index <- main_function(
datapath = input$file1$datapath,
input$part1,
input$part2,
input$part3,
input$part4,
input$max_score_part1,
input$max_score_part2,
input$max_score_part3,
input$max_score_part4,
3,
p_table = input$p_table
)
print(alpha_index)
})
#distractors:
output$distractor.anal <- renderPrint({
validate(need(try(input$file1 != "")
, "Please upload your data to see the output"))
option_level_stats <-
main_function(
datapath = input$file1$datapath,
input$part1,
input$part2,
input$part3,
input$part4,
input$max_score_part1,
input$max_score_part2,
input$max_score_part3,
input$max_score_part4,
4,
p_table = input$p_table
)
print(option_level_stats)
})
# summary_stats:
output$summary_stats <- renderPrint({
validate(need(
try(input$file1 != "")
, "Summary statistics will appear here when data is uploaded."
))
sumstats <- main_function(
datapath = input$file1$datapath,
input$part1,
input$part2,
input$part3,
input$part4,
input$max_score_part1,
input$max_score_part2,
input$max_score_part3,
input$max_score_part4,
6,
p_table = input$p_table
)
print(sumstats)
})
# discrimination and difficulty comment table
output$commenttable <- renderPrint({
validate(need(try(input$file1 != "")
, "Please upload your data to see the output"))
mycommenttable <-
main_function(
datapath = input$file1$datapath,
input$part1,
input$part2,
input$part3,
input$part4,
input$max_score_part1,
input$max_score_part2,
input$max_score_part3,
input$max_score_part4,
7,
p_table = input$p_table
)
print(mycommenttable)
})
#DD plot:
output$DD_plot <- renderPlot({
if (is.null(input$file1))
return(NULL)
scored_response_set <- main_function(
datapath = input$file1$datapath,
input$part1,
input$part2,
input$part3,
input$part4,
input$max_score_part1,
input$max_score_part2,
input$max_score_part3,
input$max_score_part4,
5,
p_table = input$p_table
)
item_dd_plot <- DDplot(scored_response_set, discrim = 'RIR', thr=0.2)
print(item_dd_plot)
})
}
######################OUTPUT#######################################################
shinyApp(ui = ui, server = server)