-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudent_segmentation_r.Rmd
More file actions
4767 lines (1945 loc) · 33.4 KB
/
student_segmentation_r.Rmd
File metadata and controls
4767 lines (1945 loc) · 33.4 KB
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
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Student Segmentation"
author: "Eli Nimy"
date: "2022-07-30"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# OULAD DATASET:
- https://analyse.kmi.open.ac.uk/open_dataset
```{r}
# Open University Learning Analytics Dataset
library(oulad)
# Data Analyis and Visualisation
library(tidyverse)
# Statistical Summary
library(tigerstats)
# Gaussian mixture model (GMM)
library(mclust)
# Interactive Data Visualization
library(highcharter)
# Fast Data operations: merging and manipulation
library(data.table)
```
## Student Virtual Learning Environment: Sum Clicks Analysis
- *code_module* – an identification code for a module.
- *code_presentation* - the identification code of the module presentation.
- *id_student* – a unique identification number for the student.
- *id_site* - an identification number for the VLE material.
- *date* – the date of student’s interaction with the material measured as the number of days since the start of the - module-presentation.
- *sum_click* – the number of times a student interacts with the material in that day.
# BOTTLENECK 1
- Where the data frame has the largest memory (10,6 million observations)
```{r}
# To get information the OULAD Data set
help.search("oulad")
# Load student VLE data from oulad library
set.seed(1234)
svle_df <- student_vle
# svle_df %>% head()
student_vle %>% head()
```
```{r}
# Percentage of missing values
sum(is.na(student_vle$sum_click))/length(student_vle$sum_click) * 100
```
```{r}
# Statistical Summary of Date indicator
favstats(student_vle$date)
```
```{r}
# Statistical Summary of Sum of Clicks
favstats(student_vle$sum_click)
```
#### Clickstream Data
- The number of times a unique student interacted with material(s) throughout the day / week / month / term / semester/ year or a specific period will be summed
- Since engagement behavior can change, the number of interaction will vary with different days / weeks or etc. As a student may have a 100 clicks in one week and 200 the next (showing higher/lower engagement) so clustering can be performed for different weeks
```{r}
clicks_df <- student_vle %>%
# filter(date >=-25 & date <= 269 &
# code_presentation %in% 2013J) %>% Filter for the dashboard (days) and semester
group_by(id_student) %>%
summarise(sum_click = sum(sum_click))
clicks_df %>% head()
```
```{r}
# Statistical Summary of Sum of Clicks for the filtered Period
favstats(clicks_df$sum_click)
```
## GMM MODEL SECTION
```{r}
# Selecting clicks for modelling
gmm_df <- select(clicks_df, sum_click)
gmm_df %>% head()
```
- Optimal Number of Components: 7 and 25
```{r}
# Fit a GMM model
set.seed(1837)
start_time <- Sys.time()
gmm_model <- Mclust(gmm_df, G=6)
end_time <- Sys.time()
```
```{r}
# Execution Time
end_time - start_time
```
```{r}
# Model Objects
print(gmm_model)
```
```{r}
# Summary table
summary(gmm_model)
```
```{r}
# Cluster Means/Engagement Levels
gmm_model$parameters$mean
```
- Uncertainty: A value (0-1 or 0% - 100%) expressing the degree of uncertainty in a student belonging to a group
```{r}
# Add clusters and uncertainty values to original dataset
clicks_df$engagement_level <- gmm_model$classification
clicks_df$uncertainty <- gmm_model$uncertainty
clicks_df %>% head()
```
```{r}
# Exclude scientific outputs
options(scipen=999)
# View data set
# View(clicks_df)
```
# Probability of Student belonging to each engagement level
```{r}
# Probability of a student belonging to a engagement level
engagement_level_probabilities <- gmm_model$z
colnames(engagement_level_probabilities) <- paste0('engagement_level', 1:gmm_model$G)
options(scipen=999)
# Create probabilities data frame
engagement_level_probabilities <- engagement_level_probabilities %>%
round(2) %>%
as.data.frame()
engagement_level_probabilities %>% head()
```
- A table with the probability of a student belonging to each cluster, the cluster a student belongs to and the uncertainty with a student belonging to the particular cluster
```{r}
# Add cluster belonging of student
engagement_level_probabilities$engagement_level <- clicks_df$engagement_level
engagement_level_probabilities$uncertainty <- round(gmm_model$uncertainty*100,2)
engagement_level_probabilities$sum_click <- clicks_df$sum_click
engagement_level_probabilities$id_student <- clicks_df$id_student
engagement_level_probabilities %>% head()
```
#### Cluster Mean Table
```{r}
engagement_level_avg_df <- as.data.frame(round(gmm_model$parameters$mean))
colnames(engagement_level_avg_df) <- "average_clicks"
engagement_level_avg_df
# Rename rownames to engagement_level
engagement_level_avg_df <- cbind(engagement_level = rownames(engagement_level_avg_df), engagement_level_avg_df)
# Remove rownames
rownames(engagement_level_avg_df) <- NULL
engagement_level_avg_df
```
#### Engagement Level Count Table
```{r}
# Obtain number of observations in each cluster.
engagement_level_count_df <- clicks_df %>%
group_by(engagement_level) %>%
summarise(Number_of_students = n()) #%>%
# arrange(Number_of_students)
engagement_level_count_df
```
#### Engagement Level Statistics Table
```{r}
engagement_level_stats <- merge(engagement_level_avg_df, engagement_level_count_df) %>% arrange(average_clicks)
engagement_level_stats
```
#### Distribution of Probabilities in each Engagement Level
```{r}
# probabilities <- select(cluster_probabilitics, -cluster, -uncertainty, -id_student) %>%
# as.data.frame() %>%
# mutate(id = row_number()) %>%
# tidyr::gather(cluster, probability, -id)
#
# ggplot(probabilities, aes(probability)) +
# geom_histogram() +
# facet_wrap(~ cluster, nrow = 6)
```
## Engagement Level Analysis Tab
```{r}
# Data Visualization
library(highcharter)
```
- Highcharter default colors: https://api.highcharts.com/highcharts/colors
```{r}
hchart(engagement_level_stats, "column", hcaes(x = engagement_level, y = average_clicks),
dataLabels = list(enabled = TRUE),
name = "Average No. of Clicks") %>%
hc_title(
text = paste0("Average Number of Clicks for Each Engagement Level")
) %>%
hc_xAxis(title = list(text = "Engagement Level")) %>%
hc_yAxis(title = list(text = "Average Number of Clicks"))
```
```{r}
hchart(engagement_level_stats, "column", hcaes(x = engagement_level, y = Number_of_students),
dataLabels = list(enabled = TRUE),
name = "No of Students") %>%
hc_title(
text = paste0("Number of Students in Each Engagement Level")
) %>%
hc_xAxis(title = list(text = "Engagement Level")) %>%
hc_yAxis(title = list(text = "Number of Students")) %>%
hc_exporting(
enabled = TRUE)
```
- Add min, max, average statistical summary of uncertainty
- Add short caption explanation
```{r}
hchart(engagement_level_probabilities$uncertainty, color = "#B71C1C", name = "Uncertainty") %>%
hc_title(
text = paste0("Distribution of Engagement Level Assignment Uncertainty")
) %>%
hc_xAxis(title = list(text = "Uncertainty"),
labels = list(format = "{value}%")) %>%
hc_yAxis(title = list(text = "Number of Students"))
```
```{r}
# Boxplot of clicks
bp_clicks <- data_to_boxplot(data = clicks_df,
variable = sum_click,
add_outliers = FALSE,
fillColor = "#B71C1C",
color = "black")
highchart() %>%
hc_xAxis(type = "category",
title = list(text = "Clicks")) %>%
hc_yAxis(title = list(text = "Number of Clicks")) %>%
hc_title(
text = paste0("Statistical Summary of Clickstream Data without Outliers")
) %>%
hc_add_series_list(bp_clicks) %>%
hc_legend(FALSE)
```
```{r}
# Boxplot of clicks
bp_clicks_outlier <- data_to_boxplot(data = clicks_df,
variable = sum_click,
add_outliers = TRUE,
fillColor = "#B71C1C",
color = "black")
highchart() %>%
hc_xAxis(type = "category",
title = list(text = "Clicks")) %>%
hc_yAxis(title = list(text = "Sum of Clicks")) %>%
hc_title(
text = paste0("Statistical Summary of Clickstream Data with Outliers")
) %>%
hc_add_series_list(bp_clicks_outlier) %>%
hc_legend(FALSE)
```
```{r}
hchart(clicks_df$sum_click, color = "#B71C1C", name = "Clicks") %>%
hc_title(
text = paste0("Distribution of Clickstream Data")
) %>%
hc_xAxis(title = list(text = "Number of Clicks")) %>%
hc_yAxis(title = list(text = "Number of Students"))
```
```{r}
# Minimum, Maximum, Average Sum of clicks values
print(min(engagement_level_probabilities$sum_click))
print(max(engagement_level_probabilities$sum_click))
print(round(mean(engagement_level_probabilities$sum_click),2))
# Average Uncertainty value
print(round(mean(engagement_level_probabilities$uncertainty),2))
```
```{r}
# Probability Table
DT::datatable(engagement_level_probabilities,
rownames = T,
filter = "top",
options = list(pageLength = 2, scrollX = TRUE, info = FALSE))
```
## INSTRUCTIONAL METHODS TAB
### Virtual Learning Environment Data
The csv file contains information about the available materials in the VLE. Typically these are html pages, pdf files, etc. Students have access to these materials online and their interactions with the materials are recorded. The vle.csv file contains the following columns:
_ **id_site** – an identification number of the material.
- **code_module** – an identification code for module.
- **code_presentation** - the identification code of presentation.
- **activity_type** – the role associated with the module material.
- **week_from** – the week from which the material is planned to be used.
- **week_to** – week until which the material is planned to be used.
```{r}
#vle_df <- vle
# vle_df
vle %>% head()
```
# BOTTLENECK 2
- Where the code takes on the longest to execute and has the data frame has the largest memory
```{r}
# Merging the dataframes to link students with activities
# Long execution code
# Replace svle_df with student_vle
svle_vle_df <- data.table::merge.data.table(svle_df, vle, by = "id_site")
svle_vle_df
```
```{r}
# Long execution code
# Number of Times student accessed an activity
activity_df <- svle_vle_df %>%
group_by(id_student,activity_type) %>%
summarise(activity_access_count = n()) %>%
as.data.frame()
activity_df
```
```{r}
# Merging data frames
clicks_activity_df <- merge.data.table(activity_df, clicks_df, by = "id_student")
clicks_activity_df
```
Activity Categories
- Resources - resource, oucontent, folder, ouwiki, glossary, url
- Assessment - quiz, questionnaire, external quiz
- VLE Site/App - dualpane, repeatactivity, htmlactivity, sharedsubpage, ouelluminate, dataplus, page, homepage, forumng, subpage, oucollaborate
```{r}
# clicks_activity_df <- clicks_activity_df %>%
# mutate(vle_activity = case_when(grepl("resource", activity_type) ~ "Resource",
# grepl("oucontent", activity_type) ~ "Resource",
# grepl("url", activity_type) ~ "Resource",
# grepl("ouwiki", activity_type) ~ "Resource",
# grepl("glossary", activity_type) ~ "Resource",
# grepl("folder", activity_type) ~ "Resource",
# grepl("quiz", activity_type) ~ "Assessment",
# grepl("questionnaire", activity_type) ~ "Assessment",
# grepl("externalquiz", activity_type) ~ "Assessment",
# grepl("subpage", activity_type) ~ "VLE Site/App",
# grepl("forumng", activity_type) ~ "VLE Site/App",
# grepl("page", activity_type) ~ "VLE Site/App",
# grepl("oucollaborate", activity_type) ~ "VLE Site/App",
# grepl("dataplus", activity_type) ~ "VLE Site/App",
# grepl("homepage", activity_type) ~ "VLE Site/App",
# grepl("ouelluminate", activity_type) ~ "VLE Site/App",
# grepl("dualpane", activity_type) ~ "VLE Site/App",
# grepl("repeatactivity", activity_type) ~ "VLE Site/App",
# grepl("htmlactivity", activity_type) ~ "VLE Site/App",
# grepl("sharedsubpage", activity_type) ~ "VLE Site/App"))
# clicks_activity_df
```
```{r}
# Number of occurrences for each activity
# table(clicks_activity_df$vle_activity)
```
```{r}
# Occurrences of activity types per cluster
# clicks_activity_df %>%
# group_by(cluster, vle_activity) %>%
# summarise(activity_access_count = n())
```
```{r}
activity_stats <- clicks_activity_df %>%
filter(engagement_level %in% 1) %>% # dashboard filter: single number select
group_by(engagement_level, activity_type) %>%
summarise(activity_access_count = n()) %>%
mutate(activity_access_percent = round(activity_access_count / sum(activity_access_count) * 100, 2)) %>%
arrange(desc(activity_access_percent))
activity_stats
```
```{r}
hchart(activity_stats, "column", hcaes(x = activity_type, y = activity_access_percent),
dataLabels = list(enabled = TRUE, format = "{y}%"),
name = "% of Students") %>%
hc_title(
text = paste0("Percentage of Students that Access each VLE Activity in Engagement Level ", 1)
) %>%
hc_xAxis(title = list(text = "VLE Activity")) %>%
hc_yAxis(title = list(text = "Percentage of Students"),
labels = list(format = "{value}%")) %>%
hc_exporting(
enabled = TRUE)
```
- source: https://www.datanovia.com/en/lessons/highchart-interactive-bar-plot-in-r/
- Color options are included
- New Title: VLE Activities Accessed by Engagement Level(s)
- description: Percentage of Students that Access each VLE Activity in Engagement Level
```{r}
# Comparison between engagement levels
# Maximum number of comparison should be limited to 3 in dashboard select
activity_stats <- clicks_activity_df %>%
filter(engagement_level %in% c(1,2, 3)) %>%
group_by(engagement_level, activity_type) %>%
summarise(activity_access_count = n()) %>%
mutate(activity_access_percent = round(activity_access_count / sum(activity_access_count) * 100, 1)) %>%
arrange(desc(activity_access_percent))
hchart(activity_stats, "column", hcaes(x = activity_type, y = activity_access_percent, group = engagement_level),
dataLabels = list(enabled = TRUE, format = "{y}"),
stacking = "normal") %>%
hc_title(
text = paste0("Percentage of Students that Access each VLE Activity in Engagement Level")
) %>%
hc_xAxis(title = list(text = "VLE Activity")) %>%
hc_yAxis(title = list(text = "Percentage of Students"),
labels = list(format = "{value}%")) %>%
hc_legend(title = list(text = "Engagement Level")) %>%
hc_exporting(
enabled = TRUE)
```
```{r}
# Module Analysis
# Number of Times student accessed a module on the VLE
# module_df <- svle_vle_df %>%
# group_by(id_student,code_module.x) %>%
# summarise(module_acess_count = n()) %>%
# as.data.frame()
# module_df
# clicks_module_df <- merge.data.table(module_df, clicks_df, by = "id_student")
# clicks_module_df
# module_stats <- clicks_module_df %>%
# filter(engagement_level %in% c(1,2,3,4,5,6)) %>% # default: 4,5,6
# group_by(engagement_level, code_module.x) %>%
# summarise(module_access_count = n()) %>%
# mutate(module_access_percent = round(module_access_count / sum(module_access_count) * 100, 1)) %>%
# arrange(desc(module_access_percent))
# module_stats
```
```{r}
# Merging with student info data frame
# si <- read_csv("oulad/studentInfo.csv", show_col_types = FALSE)
# si$num_of_prev_attempts <- as.integer(si$num_of_prev_attempts)
# si <- as.data.frame(si)
clicks_student_df <- merge.data.table(student, clicks_df, by = "id_student") # si was student
clicks_student_df
```
```{r}
module_stats <- clicks_student_df %>%
filter(engagement_level %in% c(1:6)) %>% # default: all
group_by(engagement_level, code_module) %>%
summarise(number_of_students = n()) %>%
mutate(percentage_of_students = round(number_of_students / sum(number_of_students) * 100, 1)) %>%
arrange(desc(percentage_of_students))
module_stats
```
```{r}
hchart(module_stats, "column", hcaes(x = code_module, y = percentage_of_students, group = engagement_level),
dataLabels = list(enabled = TRUE, format = "{y}%")) %>%
hc_title(
text = paste0("Modules Accessed by Engagement Level(s):")
) %>%
hc_xAxis(title = list(text = "Module")) %>%
hc_yAxis(title = list(text = "Percentage of Students"),
labels = list(format = "{value}%")) %>%
hc_legend(title = list(text = "Engagement Level")) %>%
hc_exporting(
enabled = TRUE)
```
## Student Characteristic Tab
```{r}
clicks_df
```
```{r}
gender_stats <- clicks_student_df %>%
filter(engagement_level %in% c(1:6)) %>% # default: all
group_by(engagement_level, gender) %>%
summarise(number_of_students = n()) %>%
mutate(percentage_of_students = round(number_of_students / sum(number_of_students) * 100, 1)) %>%
arrange(desc(percentage_of_students))
gender_stats
```
```{r}
hchart(gender_stats, "column", hcaes(x = gender, y = percentage_of_students, group = engagement_level),
dataLabels = list(enabled = TRUE, format = "{y}%")) %>%
hc_title(
text = paste0("Gender Representation in Engagement Level(s):")
) %>%
hc_xAxis(title = list(text = "Gender")) %>%
hc_yAxis(title = list(text = "Percentage of Students"),
labels = list(format = "{value}%")) %>%
hc_legend(title = list(text = "Engagement Level")) %>%
hc_exporting(
enabled = TRUE)
```
```{r}
age_stats <- clicks_student_df %>%
filter(engagement_level %in% c(1:6)) %>% # default: all
group_by(engagement_level, age_band) %>%
summarise(number_of_students = n()) %>%
mutate(percentage_of_students = round(number_of_students / sum(number_of_students) * 100, 1)) %>%
arrange(desc(percentage_of_students))
age_stats
```
```{r}
hchart(age_stats, "column", hcaes(x = age_band, y = percentage_of_students, group = engagement_level),
dataLabels = list(enabled = TRUE, format = "{y}%")) %>%
hc_title(
text = paste0("Student Age Band Representation in Engagement Level(s):")
) %>%
hc_xAxis(title = list(text = "Age Band")) %>%
hc_yAxis(title = list(text = "Percentage of Students"),
labels = list(format = "{value}%")) %>%
hc_legend(title = list(text = "Engagement Level")) %>%
hc_exporting(
enabled = TRUE)
```
```{r}
disability_stats <- clicks_student_df %>%
filter(engagement_level %in% c(1:6)) %>% # default: all
group_by(engagement_level, disability) %>%
summarise(number_of_students = n()) %>%
mutate(percentage_of_students = round(number_of_students / sum(number_of_students) * 100, 1)) %>%
arrange(desc(percentage_of_students))
disability_stats$disability <- as.character(disability_stats$disability)
disability_stats
```
```{r}
hchart(disability_stats, "column", hcaes(x = disability, y = percentage_of_students, group = engagement_level),
dataLabels = list(enabled = TRUE, format = "{y}%")) %>%
hc_title(
text = paste0("Student with/without a Disability Representation in Engagement Level(s):")
) %>%
hc_xAxis(title = list(text = "Disability")) %>%
hc_yAxis(title = list(text = "Percentage of Students"),
labels = list(format = "{value}%")) %>%
hc_legend(title = list(text = "Engagement Level")) %>%
hc_exporting(
enabled = TRUE)
```
```{r}
final_results_stats <- clicks_student_df %>%
filter(engagement_level %in% c(1:6)) %>% # default: all
group_by(engagement_level, final_result) %>%
summarise(number_of_students = n()) %>%
mutate(percentage_of_students = round(number_of_students / sum(number_of_students) * 100, 1)) %>%
arrange(desc(percentage_of_students))
final_results_stats
```
```{r}
hchart(final_results_stats, "column", hcaes(x = final_result,
y = percentage_of_students, group = engagement_level),
dataLabels = list(enabled = TRUE, format = "{y}%")) %>%
hc_title(
text = paste0("Student Final Academic Outcome in each Engagement Level")
) %>%
hc_xAxis(title = list(text = "Final Result")) %>%
hc_yAxis(title = list(text = "Percentage of Students"),
labels = list(format = "{value}%")) %>%
hc_legend(title = list(text = "Engagement Level")) %>%
hc_exporting(
enabled = TRUE)
```
```{r}
prev_attempts_stats <- clicks_student_df %>%
filter(engagement_level %in% c(1:6)) %>% # default: all
group_by(engagement_level, num_of_prev_attempts) %>%
summarise(number_of_students = n()) %>%
mutate(percentage_of_students = round(number_of_students / sum(number_of_students) * 100, 1)) %>%
arrange(desc(percentage_of_students))
prev_attempts_stats$num_of_prev_attempts <- as.character(prev_attempts_stats$num_of_prev_attempts)
prev_attempts_stats
```
```{r}
hchart(prev_attempts_stats, "column", hcaes(x = num_of_prev_attempts,
y = percentage_of_students, group = engagement_level),
dataLabels = list(enabled = TRUE, format = "{y}%")) %>%
hc_title(
text = paste0("Number of Previous Attempts in Course according to each Engagement Level")
) %>%
hc_xAxis(title = list(text = "Number of Previous Attempts")) %>%
hc_yAxis(title = list(text = "Percentage of Students"),
labels = list(format = "{value}%")) %>%
hc_legend(title = list(text = "Engagement Level")) %>%
hc_exporting(
enabled = TRUE)
```
```{r}
region_stats <- clicks_student_df %>%
filter(engagement_level %in% c(1:2)) %>% # default: all
group_by(engagement_level, region) %>%
summarise(number_of_students = n()) %>%
mutate(percentage_of_students = round(number_of_students / sum(number_of_students) * 100, 1)) %>%
arrange(desc(percentage_of_students))
region_stats
```
```{r}
hchart(region_stats, "column", hcaes(x = region, y = percentage_of_students, group = engagement_level),
dataLabels = list(enabled = TRUE, format = "{y}%")) %>%
hc_title(
text = paste0("Engagement Level Representation based on Student's Region of Stay")
) %>%
hc_xAxis(title = list(text = "Regions")) %>%
hc_yAxis(title = list(text = "Percentage of Students"),
labels = list(format = "{value}%")) %>%
hc_legend(title = list(text = "Engagement Level")) %>%
hc_exporting(
enabled = TRUE)
```
## LIBRARY & DOWNLOADED DATA READ
```{r}
student_vle
read_csv("oulad_original/studentVle.csv")
```
```{r}
vle
read_csv("oulad_original/vle.csv")
```
```{r}
si <- read_csv("oulad_original/studentInfo.csv", show_col_types = FALSE)
si$num_of_prev_attempts <- as.integer(si$num_of_prev_attempts)
student
```
# Data Reduction
- Creating a subset of the original data to use on the deployed dashboard
```{r}
# Reading data
library(tidyverse)
svle_df <- read_csv("oulad_original/studentVle.csv") %>% as.data.frame()
#set.seed(1234)
# Sampling 100 000
svle_df2 <- sample_n(svle_df, 100000)
# Data Sampling Per Year
library(tigerstats)
#set.seed(1537)
B_2013 = subset(svle_df,code_presentation == "2013B")
B_2013 = popsamp(25000,B_2013)
#set.seed(1637)
J_2013 = subset(svle_df,code_presentation == "2013J")
J_2013 = popsamp(25000,J_2013)
#set.seed(1737)
B_2014 = subset(svle_df,code_presentation == "2014B")
B_2014 = popsamp(25000,B_2014)
#set.seed(1837)
J_2014 = subset(svle_df,code_presentation == "2014J")
J_2014 = popsamp(25000,J_2014)
svle_df3 <- rbind(B_2013, J_2013, B_2014, J_2014)
svle_df3
```
## COMPARING SAMPLE RESULTS
```{r}
# Ogriginal Data Sum of Clicks statistical summary
favstats(svle_df$sum_click)
```
```{r}
favstats(svle_df2$sum_click)
```
```{r}
favstats(svle_df3$sum_click)
```
```{r}
# For observing memory size
vle_df <- read_csv("oulad_original/vle.csv") %>% as.data.frame()
svle_vle_df <- data.table::merge.data.table(svle_df3, vle_df, by = "id_site")
svle_vle_df
```
```{r}
# Saving the subsetted data
# write.csv(svle_df3,'oulad2/studentVle.csv', row.names = FALSE)
```
```{r}
# read_csv("oulad2/studentVle.csv", show_col_types = FALSE)
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```
```{r}
```