Stršila

Column

Box plot

Column

Summary (sa stršilima)

    osoba                LO_1            LO_2             LO_3      
 Length:99          Min.   :2.020   Min.   : 2.580   Min.   : 3.00  
 Class :character   1st Qu.:4.470   1st Qu.: 9.705   1st Qu.: 4.00  
 Mode  :character   Median :6.040   Median :11.560   Median :11.07  
                    Mean   :5.886   Mean   :10.874   Mean   :11.20  
                    3rd Qu.:7.085   3rd Qu.:12.835   3rd Qu.:16.16  
                    Max.   :9.730   Max.   :14.000   Max.   :25.71  
      LO_4            LO_5            LO_6       
 Min.   :1.930   Min.   : 0.00   Min.   : 0.190  
 1st Qu.:3.995   1st Qu.:15.31   1st Qu.: 3.705  
 Median :5.870   Median :16.50   Median : 5.760  
 Mean   :5.368   Mean   :16.93   Mean   : 6.135  
 3rd Qu.:6.790   3rd Qu.:19.29   3rd Qu.: 8.115  
 Max.   :7.830   Max.   :25.25   Max.   :29.100  

Summary (bez stršila)

    osoba                LO_1            LO_2            LO_3      
 Length:93          Min.   :2.020   Min.   : 5.10   Min.   : 3.00  
 Class :character   1st Qu.:4.640   1st Qu.: 9.94   1st Qu.: 4.00  
 Mode  :character   Median :6.130   Median :11.60   Median :11.12  
                    Mean   :5.985   Mean   :11.11   Mean   :11.53  
                    3rd Qu.:7.130   3rd Qu.:12.84   3rd Qu.:17.66  
                    Max.   :9.730   Max.   :14.00   Max.   :25.71  
      LO_4            LO_5            LO_6       
 Min.   :1.930   Min.   :10.78   Min.   : 0.330  
 1st Qu.:4.080   1st Qu.:15.50   1st Qu.: 3.730  
 Median :5.910   Median :16.73   Median : 5.830  
 Mean   :5.411   Mean   :17.32   Mean   : 6.024  
 3rd Qu.:6.810   3rd Qu.:19.40   3rd Qu.: 8.160  
 Max.   :7.830   Max.   :23.91   Max.   :13.550  

Dendrogram

Column

Tri klastera

Column

Broj studenata u klasterima

  klaster  n
1       1 43
2       2 30
3       3 20

Silhouette

Column

Silhouette

Column

info

Silhouette of 93 units in 3 clusters from silhouette.default(x = data3_cluster3$klaster, dist = dist(data3)) :
 Cluster sizes and average silhouette widths:
       43        30        20 
0.1402482 0.2727194 0.2149789 
Individual silhouette widths:
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-0.1134  0.1038  0.2145  0.1991  0.2953  0.4591 

Vizualizacija klastera

Column

Funkcije gustoća za pojedini ishod

Column

Funkcije gustoća za pojedini ishod unutar klastera

Dendrogram

Column

Četiri klastera

Column

Broj studenata u klasterima

  klaster  n
1       1 31
2       2 12
3       3 30
4       4 20

Silhouette

Column

Silhouette

Column

info

Silhouette of 93 units in 4 clusters from silhouette.default(x = data3_cluster4$klaster, dist = dist(data3)) :
 Cluster sizes and average silhouette widths:
        31         12         30         20 
0.22823381 0.04202407 0.23946359 0.20579379 
Individual silhouette widths:
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-0.1790  0.1072  0.2412  0.2030  0.3034  0.4250 

Vizualizacija klastera

Column

Funkcije gustoća za pojedini ishod

Column

Funkcije gustoća za pojedini ishod unutar klastera

Funkcije gustoća

Column

Tri klastera

Column

Četiri klastera

Tablice studenata

Column

Tri klastera

Tablica s tri klastera
osoba LO_1 LO_2 LO_3 LO_4 LO_5 LO_6 ukupno klaster
student_64 2.18 11.60 25.71 4.21 21.75 11.07 76.52 1
student_69 5.44 10.54 22.58 2.99 20.57 8.46 70.58 1
student_96 5.69 8.91 23.84 2.26 20.17 7.25 68.12 1
student_1 4.90 10.15 18.73 5.94 16.73 7.19 63.64 1
student_52 6.77 8.69 18.85 6.52 17.48 4.43 62.74 1
student_77 4.03 9.43 25.27 4.78 14.65 3.60 61.76 1
student_41 3.39 13.01 12.47 3.29 17.56 10.16 59.88 1
student_61 5.85 11.56 16.16 5.35 15.95 4.89 59.76 1
student_51 4.08 12.99 18.66 2.92 14.32 6.76 59.73 1
student_45 4.50 11.90 14.51 6.10 16.50 4.86 58.37 1
student_3 3.35 9.67 19.31 5.59 15.76 4.50 58.18 1
student_97 7.00 5.10 19.25 1.93 15.50 9.33 58.11 1
student_55 2.02 13.98 15.22 2.43 16.15 7.34 57.14 1
student_44 5.14 8.54 11.00 4.86 20.84 5.98 56.36 1
student_2 2.49 10.04 19.47 2.67 15.99 5.43 56.09 1
student_37 5.61 11.05 11.43 4.56 15.68 6.81 55.14 1
student_40 4.42 8.92 13.01 5.35 16.50 6.93 55.13 1
student_98 4.44 11.00 12.13 6.56 14.37 5.33 53.83 1
student_8 5.13 9.21 11.12 6.46 15.48 6.17 53.57 1
student_9 4.25 11.48 11.12 5.04 15.84 5.71 53.44 1
student_57 6.35 9.33 12.60 7.09 16.44 1.60 53.41 1
student_43 2.38 5.53 11.00 4.80 21.52 8.03 53.26 1
student_59 3.85 11.17 12.60 4.50 15.59 3.73 51.44 1
student_12 3.00 12.11 10.61 7.12 15.79 2.28 50.91 1
student_20 5.69 12.33 7.73 4.73 16.17 3.66 50.31 1
student_58 6.10 8.00 12.00 4.08 16.50 2.31 48.99 1
student_11 5.57 9.81 9.43 6.27 13.44 1.60 46.12 1
student_62 2.33 8.13 16.16 3.28 10.78 5.25 45.93 1
student_42 6.72 5.58 10.00 2.32 11.16 9.07 44.85 1
student_49 7.29 9.06 5.00 2.30 17.94 3.19 44.78 1
student_26 3.88 10.32 3.00 3.96 18.13 4.72 44.01 1
student_7 5.75 6.89 11.12 2.50 16.43 1.00 43.69 1
student_89 3.73 11.11 3.00 5.18 13.75 5.59 42.36 1
student_50 4.99 10.09 5.00 2.87 16.31 2.89 42.15 1
student_35 2.33 9.74 3.00 6.77 15.09 4.43 41.36 1
student_17 6.62 9.57 4.00 5.61 12.24 2.16 40.20 1
student_75 5.58 8.65 4.00 4.01 15.41 2.29 39.94 1
student_24 3.33 10.66 3.00 3.60 16.29 2.47 39.35 1
student_34 3.38 9.94 3.00 3.66 17.55 0.33 37.86 1
student_48 4.01 5.46 5.00 3.61 18.36 0.35 36.79 1
student_30 4.64 5.69 3.00 6.85 11.84 4.23 36.25 1
student_33 4.94 8.50 3.00 6.06 13.10 0.60 36.20 1
student_73 2.13 7.53 6.00 3.68 14.00 0.60 33.94 1
student_80 5.90 13.16 19.03 5.87 23.42 4.50 71.88 2
student_36 7.88 13.25 11.83 6.75 21.50 8.16 69.37 2
student_83 8.25 14.00 5.00 7.27 22.24 9.00 65.76 2
student_19 6.63 13.11 6.33 7.16 21.73 8.62 63.58 2
student_39 7.50 13.09 13.20 4.84 21.08 3.69 63.40 2
student_46 4.37 12.72 14.51 4.19 22.48 3.72 61.99 2
student_71 7.00 13.86 8.73 6.33 18.24 6.86 61.02 2
student_94 7.17 14.00 5.00 6.92 19.17 8.07 60.33 2
student_66 9.25 12.38 3.00 6.56 19.81 9.00 60.00 2
student_38 6.25 13.59 11.43 3.71 17.60 6.17 58.75 2
student_27 5.38 12.85 14.27 5.72 18.40 2.05 58.67 2
student_76 8.54 13.47 4.00 5.91 19.40 7.25 58.57 2
student_67 9.73 13.68 3.00 7.38 20.11 4.43 58.33 2
student_14 9.14 12.84 4.00 7.11 19.86 4.50 57.45 2
student_13 9.17 12.52 4.00 7.09 17.84 6.23 56.85 2
student_5 8.75 12.45 4.00 7.10 17.48 5.83 55.61 2
student_93 7.04 13.60 5.00 3.90 17.96 7.94 55.44 2
student_6 9.42 12.98 4.00 6.67 15.67 5.71 54.45 2
student_72 8.92 12.38 6.00 3.28 19.46 4.16 54.20 2
student_84 6.54 13.04 5.00 7.83 15.75 5.76 53.92 2
student_16 6.92 13.70 4.00 6.40 18.54 4.10 53.66 2
student_31 8.74 10.60 3.00 7.42 17.32 6.58 53.66 2
student_4 6.13 12.05 4.00 6.63 17.45 6.90 53.16 2
student_65 6.38 12.31 3.00 4.93 23.44 2.89 52.95 2
student_18 6.33 12.96 4.00 7.02 18.13 4.10 52.54 2
student_15 6.60 12.17 4.00 7.15 18.67 2.18 50.77 2
student_74 6.63 12.28 4.00 6.10 15.21 5.93 50.15 2
student_32 7.63 10.62 3.00 2.70 23.59 2.17 49.71 2
student_25 5.87 10.04 3.00 6.55 16.03 4.77 46.26 2
student_90 5.87 12.10 3.00 6.77 13.88 2.03 43.65 2
student_79 8.33 12.83 25.27 7.31 22.71 11.47 87.92 3
student_22 8.25 13.71 22.97 6.92 23.73 10.58 86.16 3
student_88 6.86 12.82 23.85 6.46 20.94 13.55 84.48 3
student_70 7.13 12.36 22.58 6.84 21.52 10.46 80.89 3
student_86 6.38 12.28 24.20 7.63 17.85 9.79 78.13 3
student_82 6.04 11.44 19.30 6.86 20.52 13.15 77.31 3
student_81 8.38 11.70 18.66 5.35 23.91 7.59 75.59 3
student_78 8.12 12.25 25.27 7.26 13.56 8.88 75.34 3
student_23 6.76 13.02 22.97 6.45 17.05 8.64 74.89 3
student_87 7.25 11.64 24.20 6.86 15.12 8.88 73.95 3
student_53 6.51 13.00 18.97 4.40 17.16 12.65 72.69 3
student_63 5.17 10.33 24.12 6.13 12.40 11.40 69.55 3
student_56 4.66 13.01 15.86 5.25 17.80 10.60 67.18 3
student_95 5.75 11.84 17.66 5.92 14.84 9.31 65.32 3
student_60 6.51 10.14 14.69 7.10 16.28 9.88 64.60 3
student_47 8.61 11.27 13.73 6.87 15.75 5.52 61.75 3
student_29 6.75 12.44 13.71 6.81 14.50 6.38 60.59 3
student_28 6.75 10.68 13.39 5.95 13.81 7.00 57.58 3
student_54 8.40 9.94 15.43 3.56 12.48 7.29 57.10 3
student_21 8.75 11.51 6.33 5.40 15.73 9.33 57.05 3

Column

Četiri klastera

Tablica s četiri klastera
osoba LO_1 LO_2 LO_3 LO_4 LO_5 LO_6 ukupno klaster
student_1 4.90 10.15 18.73 5.94 16.73 7.19 63.64 1
student_52 6.77 8.69 18.85 6.52 17.48 4.43 62.74 1
student_77 4.03 9.43 25.27 4.78 14.65 3.60 61.76 1
student_61 5.85 11.56 16.16 5.35 15.95 4.89 59.76 1
student_45 4.50 11.90 14.51 6.10 16.50 4.86 58.37 1
student_3 3.35 9.67 19.31 5.59 15.76 4.50 58.18 1
student_37 5.61 11.05 11.43 4.56 15.68 6.81 55.14 1
student_40 4.42 8.92 13.01 5.35 16.50 6.93 55.13 1
student_98 4.44 11.00 12.13 6.56 14.37 5.33 53.83 1
student_8 5.13 9.21 11.12 6.46 15.48 6.17 53.57 1
student_9 4.25 11.48 11.12 5.04 15.84 5.71 53.44 1
student_57 6.35 9.33 12.60 7.09 16.44 1.60 53.41 1
student_59 3.85 11.17 12.60 4.50 15.59 3.73 51.44 1
student_12 3.00 12.11 10.61 7.12 15.79 2.28 50.91 1
student_20 5.69 12.33 7.73 4.73 16.17 3.66 50.31 1
student_58 6.10 8.00 12.00 4.08 16.50 2.31 48.99 1
student_11 5.57 9.81 9.43 6.27 13.44 1.60 46.12 1
student_49 7.29 9.06 5.00 2.30 17.94 3.19 44.78 1
student_26 3.88 10.32 3.00 3.96 18.13 4.72 44.01 1
student_7 5.75 6.89 11.12 2.50 16.43 1.00 43.69 1
student_89 3.73 11.11 3.00 5.18 13.75 5.59 42.36 1
student_50 4.99 10.09 5.00 2.87 16.31 2.89 42.15 1
student_35 2.33 9.74 3.00 6.77 15.09 4.43 41.36 1
student_17 6.62 9.57 4.00 5.61 12.24 2.16 40.20 1
student_75 5.58 8.65 4.00 4.01 15.41 2.29 39.94 1
student_24 3.33 10.66 3.00 3.60 16.29 2.47 39.35 1
student_34 3.38 9.94 3.00 3.66 17.55 0.33 37.86 1
student_48 4.01 5.46 5.00 3.61 18.36 0.35 36.79 1
student_30 4.64 5.69 3.00 6.85 11.84 4.23 36.25 1
student_33 4.94 8.50 3.00 6.06 13.10 0.60 36.20 1
student_73 2.13 7.53 6.00 3.68 14.00 0.60 33.94 1
student_64 2.18 11.60 25.71 4.21 21.75 11.07 76.52 2
student_69 5.44 10.54 22.58 2.99 20.57 8.46 70.58 2
student_96 5.69 8.91 23.84 2.26 20.17 7.25 68.12 2
student_41 3.39 13.01 12.47 3.29 17.56 10.16 59.88 2
student_51 4.08 12.99 18.66 2.92 14.32 6.76 59.73 2
student_97 7.00 5.10 19.25 1.93 15.50 9.33 58.11 2
student_55 2.02 13.98 15.22 2.43 16.15 7.34 57.14 2
student_44 5.14 8.54 11.00 4.86 20.84 5.98 56.36 2
student_2 2.49 10.04 19.47 2.67 15.99 5.43 56.09 2
student_43 2.38 5.53 11.00 4.80 21.52 8.03 53.26 2
student_62 2.33 8.13 16.16 3.28 10.78 5.25 45.93 2
student_42 6.72 5.58 10.00 2.32 11.16 9.07 44.85 2
student_80 5.90 13.16 19.03 5.87 23.42 4.50 71.88 3
student_36 7.88 13.25 11.83 6.75 21.50 8.16 69.37 3
student_83 8.25 14.00 5.00 7.27 22.24 9.00 65.76 3
student_19 6.63 13.11 6.33 7.16 21.73 8.62 63.58 3
student_39 7.50 13.09 13.20 4.84 21.08 3.69 63.40 3
student_46 4.37 12.72 14.51 4.19 22.48 3.72 61.99 3
student_71 7.00 13.86 8.73 6.33 18.24 6.86 61.02 3
student_94 7.17 14.00 5.00 6.92 19.17 8.07 60.33 3
student_66 9.25 12.38 3.00 6.56 19.81 9.00 60.00 3
student_38 6.25 13.59 11.43 3.71 17.60 6.17 58.75 3
student_27 5.38 12.85 14.27 5.72 18.40 2.05 58.67 3
student_76 8.54 13.47 4.00 5.91 19.40 7.25 58.57 3
student_67 9.73 13.68 3.00 7.38 20.11 4.43 58.33 3
student_14 9.14 12.84 4.00 7.11 19.86 4.50 57.45 3
student_13 9.17 12.52 4.00 7.09 17.84 6.23 56.85 3
student_5 8.75 12.45 4.00 7.10 17.48 5.83 55.61 3
student_93 7.04 13.60 5.00 3.90 17.96 7.94 55.44 3
student_6 9.42 12.98 4.00 6.67 15.67 5.71 54.45 3
student_72 8.92 12.38 6.00 3.28 19.46 4.16 54.20 3
student_84 6.54 13.04 5.00 7.83 15.75 5.76 53.92 3
student_16 6.92 13.70 4.00 6.40 18.54 4.10 53.66 3
student_31 8.74 10.60 3.00 7.42 17.32 6.58 53.66 3
student_4 6.13 12.05 4.00 6.63 17.45 6.90 53.16 3
student_65 6.38 12.31 3.00 4.93 23.44 2.89 52.95 3
student_18 6.33 12.96 4.00 7.02 18.13 4.10 52.54 3
student_15 6.60 12.17 4.00 7.15 18.67 2.18 50.77 3
student_74 6.63 12.28 4.00 6.10 15.21 5.93 50.15 3
student_32 7.63 10.62 3.00 2.70 23.59 2.17 49.71 3
student_25 5.87 10.04 3.00 6.55 16.03 4.77 46.26 3
student_90 5.87 12.10 3.00 6.77 13.88 2.03 43.65 3
student_79 8.33 12.83 25.27 7.31 22.71 11.47 87.92 4
student_22 8.25 13.71 22.97 6.92 23.73 10.58 86.16 4
student_88 6.86 12.82 23.85 6.46 20.94 13.55 84.48 4
student_70 7.13 12.36 22.58 6.84 21.52 10.46 80.89 4
student_86 6.38 12.28 24.20 7.63 17.85 9.79 78.13 4
student_82 6.04 11.44 19.30 6.86 20.52 13.15 77.31 4
student_81 8.38 11.70 18.66 5.35 23.91 7.59 75.59 4
student_78 8.12 12.25 25.27 7.26 13.56 8.88 75.34 4
student_23 6.76 13.02 22.97 6.45 17.05 8.64 74.89 4
student_87 7.25 11.64 24.20 6.86 15.12 8.88 73.95 4
student_53 6.51 13.00 18.97 4.40 17.16 12.65 72.69 4
student_63 5.17 10.33 24.12 6.13 12.40 11.40 69.55 4
student_56 4.66 13.01 15.86 5.25 17.80 10.60 67.18 4
student_95 5.75 11.84 17.66 5.92 14.84 9.31 65.32 4
student_60 6.51 10.14 14.69 7.10 16.28 9.88 64.60 4
student_47 8.61 11.27 13.73 6.87 15.75 5.52 61.75 4
student_29 6.75 12.44 13.71 6.81 14.50 6.38 60.59 4
student_28 6.75 10.68 13.39 5.95 13.81 7.00 57.58 4
student_54 8.40 9.94 15.43 3.56 12.48 7.29 57.10 4
student_21 8.75 11.51 6.33 5.40 15.73 9.33 57.05 4

Planirani i ostvareni bodovi (slika1)

Column

Tri klastera

Četiri klastera

Planirani i ostvareni bodovi (slika2)

Column

Tri klastera

Četiri klastera

Planirani i ostvareni bodovi (slika3)

Column

Tri klastera

Column

Četiri klastera

---
title: "DSTG - Klasteriranje po ishodima (bez stršila)"
output: 
  flexdashboard::flex_dashboard:
    social: menu
    orientation: columns
    vertical_layout: fill
    source_code: embed
---

```{css, echo=FALSE}
.sidebar { overflow: auto; }
.dataTables_scrollBody {
    height:95% !important;
    max-height:95% !important;
}
.chart-stage-flex {
    overflow:auto !important;
}
```

```{r setup, include=FALSE}
library(readxl)
library(tidyverse)
library(cluster)
library(knitr)
library(kableExtra)
library(tidyverse)
library(corrplot)
library(dendextend)
library(factoextra)

data1 <- read_excel('DSTG_ishodi.xlsx', sheet=1)
data1 <- na.omit(data1)
data1_long <- data1 %>% pivot_longer(cols=LO_1:LO_6, names_to="Ishod", values_to="Vrijednost")

data1_noOutliers <- data1 %>% 
  filter(
    between(LO_1, quantile(data1$LO_1, 0.25) - 1.5*IQR(data1$LO_1), quantile(data1$LO_1, 0.75) + 1.5*IQR(data1$LO_1)),
    between(LO_2, quantile(data1$LO_2, 0.25) - 1.5*IQR(data1$LO_2), quantile(data1$LO_2, 0.75) + 1.5*IQR(data1$LO_2)),
    between(LO_3, quantile(data1$LO_3, 0.25) - 1.5*IQR(data1$LO_3), quantile(data1$LO_3, 0.75) + 1.5*IQR(data1$LO_3)),
    between(LO_4, quantile(data1$LO_4, 0.25) - 1.5*IQR(data1$LO_4), quantile(data1$LO_4, 0.75) + 1.5*IQR(data1$LO_4)),
    between(LO_5, quantile(data1$LO_5, 0.25) - 1.5*IQR(data1$LO_5), quantile(data1$LO_5, 0.75) + 1.5*IQR(data1$LO_5)),
    between(LO_6, quantile(data1$LO_6, 0.25) - 1.5*IQR(data1$LO_6), quantile(data1$LO_6, 0.75) + 1.5*IQR(data1$LO_6))
  )

data2 <- data1_noOutliers %>% select(LO_1:LO_6) 
data3 <- data.frame(scale(data2))

dist_student <- dist(data3)
hc_ward <- hclust(dist_student, method = "ward.D2")
ward_dend <- as.dendrogram(hc_ward) #%>% set("labels", 1:99)

ward_dend_color3 <- color_branches(ward_dend, k=3)
ward_dend_color4 <- color_branches(ward_dend, k=4)

klasteri3 <- cutree(hc_ward, k=3)
klasteri4 <- cutree(hc_ward, k=4)

data3_cluster3 <- data3 %>% mutate(klaster = klasteri3)
data3_cluster4 <- data3 %>% mutate(klaster = klasteri4)

data1_cluster3 <- data1_noOutliers %>% mutate(klaster = klasteri3)
data1_cluster4 <- data1_noOutliers %>% mutate(klaster = klasteri4)

AS <- data1_noOutliers %>% summarise_at(vars(LO_1:LO_6), mean, na.rm = TRUE)

rez3 <- data1_cluster3 %>% group_by(klaster) %>% 
        summarise_at(vars(LO_1:LO_6), mean, na.rm = TRUE) %>% 
        gather(Ishod, Prosjek, LO_1:LO_6)
rez3 <- rez3 %>% 
        add_row(klaster=rep(0,6), Ishod=c("LO_1","LO_2","LO_3","LO_4","LO_5","LO_6"), 
                Prosjek=as.numeric(AS))
rez3$klaster <- factor(rez3$klaster)
levels(rez3$klaster) <- c("svi", "1", "2", "3")

rez4 <- data1_cluster4 %>% group_by(klaster) %>% 
        summarise_at(vars(LO_1:LO_6), mean, na.rm = TRUE) %>% 
        gather(Ishod, Prosjek, LO_1:LO_6)
rez4 <- rez4 %>% 
        add_row(klaster=rep(0,6), Ishod=c("LO_1","LO_2","LO_3","LO_4","LO_5","LO_6"), 
                Prosjek=as.numeric(AS))
rez4$klaster <- factor(rez4$klaster)
levels(rez4$klaster) <- c("svi", "1", "2", "3", "4")

bodovi <- c(10,14,26,8,26,16)

sil3 <- silhouette(data3_cluster3$klaster, dist(data3))
sil4 <- silhouette(data3_cluster4$klaster, dist(data3))

viz3 <- data3_cluster3 %>% gather(Ishod, Bodovi, LO_1:LO_6)
viz4 <- data3_cluster4 %>% gather(Ishod, Bodovi, LO_1:LO_6)

tablica <- data1_noOutliers %>% rowwise() %>% mutate(ukupno = sum(c_across(LO_1:LO_6), na.rm = T)) %>% ungroup()
tablica3 <- tablica %>% mutate(klaster=klasteri3) %>% 
            group_by(klaster) %>% 
            arrange(desc(ukupno), .by_group = TRUE)
tablica4 <- tablica %>% mutate(klaster=klasteri4) %>% 
            group_by(klaster) %>% 
            arrange(desc(ukupno), .by_group = TRUE)

hl <- data.frame(Ishod=c("LO_1","LO_2","LO_3","LO_4","LO_5","LO_6"), 
                 Bodovi=c(10,14,26,8,26,16),
                 xcor1=rep(2.5,6), xcor2=rep(3,6), ycor=c(12,16,28,10,28,18))
```

Stršila
=======================================================================

Column {data-width=500}
-------------------------------------

### Box plot

```{r fig.width=9}
ggplot(data1_long,aes(Ishod,Vrijednost)) + 
  geom_boxplot(outlier.colour = "red")
```

Column {data-width=500}
-------------------------------------

### Summary (sa stršilima)

```{r}
summary(data1)
```

### Summary (bez stršila)

```{r}
summary(data1_noOutliers)
```


Dendrogram {data-navmenu="Tri klastera"}
=======================================================================

Column {data-width=800}
-------------------------------------

### Tri klastera
```{r fig.width=18,fig.height=10}
plot(ward_dend_color3)
```

Column {data-width=100}
-------------------------------------

### Broj studenata u klasterima
```{r}
data3_cluster3 %>% count(klaster)
```

Silhouette {data-navmenu="Tri klastera"}
=======================================================================

Column {data-width=600}
-------------------------------------

### Silhouette
```{r}
fviz_silhouette(sil3, print.summary=FALSE)
```

Column {data-width=300}
-------------------------------------

### info
```{r}
summary(sil3)
```

Vizualizacija klastera {data-navmenu="Tri klastera"}
=======================================================================

Column {data-width=250}
-------------------------------------

### Funkcije gustoća za pojedini ishod

```{r}
ggplot(viz3, aes(x=Bodovi, fill=Ishod, color=Ishod)) + 
  geom_density(alpha=.2) +
  facet_wrap(~Ishod) + theme(legend.position="none") + ylim(0,1.9)
```

Column {data-width=500}
-------------------------------------

### Funkcije gustoća za pojedini ishod unutar klastera

```{r}
ggplot(viz3, aes(x=Bodovi, fill=Ishod, color=Ishod)) + 
  geom_density(alpha=.2) + facet_grid(klaster ~ Ishod) + ylim(0,1.9) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),legend.position="none")
```

Dendrogram {data-navmenu="Četiri klastera"}
=======================================================================

Column {data-width=800}
-------------------------------------

### Četiri klastera
```{r fig.width=18,fig.height=10}
plot(ward_dend_color4)
```

Column {data-width=100}
-------------------------------------

### Broj studenata u klasterima
```{r}
data3_cluster4 %>% count(klaster)
```

Silhouette {data-navmenu="Četiri klastera"}
=======================================================================

Column {data-width=600}
-------------------------------------

### Silhouette
```{r}
fviz_silhouette(sil4, print.summary=FALSE)
```

Column {data-width=300}
-------------------------------------

### info
```{r}
summary(sil4)
```

Vizualizacija klastera {data-navmenu="Četiri klastera"}
=======================================================================

Column {data-width=250}
-------------------------------------

### Funkcije gustoća za pojedini ishod

```{r}
ggplot(viz4, aes(x=Bodovi, fill=Ishod, color=Ishod)) + 
  geom_density(alpha=.2) +
  facet_wrap(~Ishod) + theme(legend.position="none") + ylim(0,1.9)
```

Column {data-width=500}
-------------------------------------

### Funkcije gustoća za pojedini ishod unutar klastera

```{r}
ggplot(viz4, aes(x=Bodovi, fill=Ishod, color=Ishod)) + 
  geom_density(alpha=.2) + facet_grid(klaster ~ Ishod) + ylim(0,1.9) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),legend.position="none")
```

Funkcije gustoća {data-navmenu="Usporedbe klastera"}
=======================================================================

Column {data-width=500}
-------------------------------------

### Tri klastera

```{r fig.height=4}
ggplot(viz3, aes(x=Bodovi, fill=Ishod, color=Ishod)) + 
  geom_density(alpha=.2) + facet_grid(klaster ~ Ishod) + ylim(0,1.9) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),legend.position="none")
```

Column {data-width=500}
-------------------------------------

### Četiri klastera

```{r}
ggplot(viz4, aes(x=Bodovi, fill=Ishod, color=Ishod)) + 
  geom_density(alpha=.2) + facet_grid(klaster ~ Ishod) + ylim(0,1.9) +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),legend.position="none")
```

Tablice studenata {data-navmenu="Usporedbe klastera"}
=======================================================================

Column {data-width=500}
-------------------------------------

### Tri klastera

```{r}
tablica3 %>%
  kbl(caption = "Tablica s tri klastera") %>%
  kable_classic("hover",full_width = F, html_font = "Cambria")
```

Column {data-width=500}
-------------------------------------

### Četiri klastera

```{r}
tablica4 %>%
  kbl(caption = "Tablica s četiri klastera") %>%
  kable_classic("hover",full_width = F, html_font = "Cambria")
```

Planirani i ostvareni bodovi (slika1) {data-navmenu="Usporedbe klastera"}
=======================================================================

Column {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Tri klastera

```{r fig.width=15}
ggplot(rez3, aes(x=Ishod, y=Prosjek, fill=klaster, color=klaster)) + 
  geom_bar(stat="identity", width=0.4, position = position_dodge(width=0.9)) +
  geom_segment(aes(x=0.6,xend=1.4,y=bodovi[1],yend=bodovi[1]),color="black") +
  geom_segment(aes(x=1.6,xend=2.4,y=bodovi[2],yend=bodovi[2]),color="black") +
  geom_segment(aes(x=2.6,xend=3.4,y=bodovi[3],yend=bodovi[3]),color="black") +
  geom_segment(aes(x=3.6,xend=4.4,y=bodovi[4],yend=bodovi[4]),color="black") +
  geom_segment(aes(x=4.6,xend=5.4,y=bodovi[5],yend=bodovi[5]),color="black") +
  geom_segment(aes(x=5.6,xend=6.4,y=bodovi[6],yend=bodovi[6]),color="black") +
  geom_text(x=1, y=10.7, label=bodovi[1], color="black") +
  geom_text(x=2, y=14.7, label=bodovi[2], color="black") +
  geom_text(x=3, y=26.7, label=bodovi[3], color="black") +
  geom_text(x=4, y=8.7, label=bodovi[4], color="black") +
  geom_text(x=5, y=26.7, label=bodovi[5], color="black") +
  geom_text(x=6, y=16.7, label=bodovi[6], color="black") +
  geom_text(aes(label=round(Prosjek,2)), position=position_dodge(width=0.9), vjust=-0.5)
```

### Četiri klastera

```{r fig.width=15}
ggplot(rez4, aes(x=Ishod, y=Prosjek, fill=klaster, color=klaster)) + 
  geom_bar(stat="identity", width=0.4, position = position_dodge(width=0.9)) +
  geom_segment(aes(x=0.6,xend=1.4,y=bodovi[1],yend=bodovi[1]),color="black") +
  geom_segment(aes(x=1.6,xend=2.4,y=bodovi[2],yend=bodovi[2]),color="black") +
  geom_segment(aes(x=2.6,xend=3.4,y=bodovi[3],yend=bodovi[3]),color="black") +
  geom_segment(aes(x=3.6,xend=4.4,y=bodovi[4],yend=bodovi[4]),color="black") +
  geom_segment(aes(x=4.6,xend=5.4,y=bodovi[5],yend=bodovi[5]),color="black") +
  geom_segment(aes(x=5.6,xend=6.4,y=bodovi[6],yend=bodovi[6]),color="black") +
  geom_text(x=1, y=10.7, label=bodovi[1], color="black") +
  geom_text(x=2, y=14.7, label=bodovi[2], color="black") +
  geom_text(x=3, y=26.7, label=bodovi[3], color="black") +
  geom_text(x=4, y=8.7, label=bodovi[4], color="black") +
  geom_text(x=5, y=26.7, label=bodovi[5], color="black") +
  geom_text(x=6, y=16.7, label=bodovi[6], color="black") +
  geom_text(aes(label=round(Prosjek,2)), position=position_dodge(width=0.9), vjust=-0.5)
```

Planirani i ostvareni bodovi (slika2) {data-navmenu="Usporedbe klastera"}
=======================================================================

Column {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Tri klastera

```{r fig.width=10}
ggplot() + 
  geom_bar(data=rez3, aes(x=klaster, y=Prosjek, fill=klaster, color=klaster), stat="identity", width=0.65, position = position_dodge(width=0.9)) +
  facet_wrap(~Ishod) + 
  geom_hline(data= hl, aes(yintercept=Bodovi)) +
  geom_text(data = hl, aes(x=xcor1, y=ycor, label=Bodovi)) +
  geom_text(data=rez3, aes(x=klaster, y=Prosjek, label=round(Prosjek,2)), vjust=1.5)
```


### Četiri klastera

```{r fig.width=10}
ggplot() + 
  geom_bar(data=rez4, aes(x=klaster, y=Prosjek, fill=klaster, color=klaster), stat="identity", width=0.75, position = position_dodge(width=0.9)) +
  facet_wrap(~Ishod) + 
  geom_hline(data= hl, aes(yintercept=Bodovi)) +
  geom_text(data = hl, aes(x=xcor2, y=ycor, label=Bodovi)) +
  geom_text(data=rez4, aes(x=klaster, y=Prosjek, label=round(Prosjek,2)), vjust=1)
```

Planirani i ostvareni bodovi (slika3) {data-navmenu="Usporedbe klastera"}
=======================================================================

Column {data-width=500}
-------------------------------------

### Tri klastera

```{r fig.width=9}
ggplot(data=rez3, aes(x=klaster, y=Prosjek, fill=klaster, color=klaster)) + 
  geom_bar(stat="identity", width=0.65, position = position_dodge(width=0.9)) +
  geom_text(aes(label=round(Prosjek,2)), vjust=-0.3) + expand_limits(y = c(0, 27)) +
  facet_wrap(~Ishod, scales="free",
             labeller=as_labeller(c(LO_1="LO_1 (max: 10)", LO_2="LO_2 (max: 14)", LO_3="LO_3 (max: 26)",
                                  LO_4="LO_4 (max: 8)", LO_5="LO_5 (max: 26)", LO_6="LO_6 (max: 16)")))
```

Column {data-width=500}
-------------------------------------

### Četiri klastera

```{r fig.width=9}
ggplot(data=rez4, aes(x=klaster, y=Prosjek, fill=klaster, color=klaster)) + 
  geom_bar(stat="identity", width=0.65, position = position_dodge(width=0.9)) +
  geom_text(aes(label=round(Prosjek,2)), vjust=-0.3) + expand_limits(y = c(0, 27)) +
  facet_wrap(~Ishod, scales="free",
             labeller=as_labeller(c(LO_1="LO_1 (max: 10)", LO_2="LO_2 (max: 14)", LO_3="LO_3 (max: 26)",
                                    LO_4="LO_4 (max: 8)", LO_5="LO_5 (max: 26)", LO_6="LO_6 (max: 16)")))
```