Dendrogram

Column

Tri klastera

Column

Broj studenata u klasterima

  klaster  n
1       1 17
2       2 45
3       3 37

Silhouette

Column

Silhouette

Column

info

Silhouette of 99 units in 3 clusters from silhouette.default(x = data3_cluster3$klaster, dist = dist(data3)) :
 Cluster sizes and average silhouette widths:
       17        45        37 
0.2551505 0.1142679 0.2901968 
Individual silhouette widths:
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-0.1634  0.1080  0.2031  0.2042  0.3250  0.4918 

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 17
2       2 42
3       3 37
4       4  3

Silhouette

Column

Silhouette

Column

info

Silhouette of 99 units in 4 clusters from silhouette.default(x = data3_cluster4$klaster, dist = dist(data3)) :
 Cluster sizes and average silhouette widths:
       17        42        37         3 
0.2498484 0.1191903 0.2733332 0.4550171 
Individual silhouette widths:
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-0.1194  0.1000  0.2073  0.2094  0.3309  0.4726 

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_79 8.33 12.83 25.27 7.31 22.71 11.47 87.92 1
student_22 8.25 13.71 22.97 6.92 23.73 10.58 86.16 1
student_88 6.86 12.82 23.85 6.46 20.94 13.55 84.48 1
student_70 7.13 12.36 22.58 6.84 21.52 10.46 80.89 1
student_86 6.38 12.28 24.20 7.63 17.85 9.79 78.13 1
student_82 6.04 11.44 19.30 6.86 20.52 13.15 77.31 1
student_81 8.38 11.70 18.66 5.35 23.91 7.59 75.59 1
student_78 8.12 12.25 25.27 7.26 13.56 8.88 75.34 1
student_23 6.76 13.02 22.97 6.45 17.05 8.64 74.89 1
student_87 7.25 11.64 24.20 6.86 15.12 8.88 73.95 1
student_53 6.51 13.00 18.97 4.40 17.16 12.65 72.69 1
student_99 4.54 11.93 4.00 4.35 17.75 29.10 71.67 1
student_63 5.17 10.33 24.12 6.13 12.40 11.40 69.55 1
student_56 4.66 13.01 15.86 5.25 17.80 10.60 67.18 1
student_95 5.75 11.84 17.66 5.92 14.84 9.31 65.32 1
student_60 6.51 10.14 14.69 7.10 16.28 9.88 64.60 1
student_1 4.90 10.15 18.73 5.94 16.73 7.19 63.64 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_77 4.03 9.43 25.27 4.78 14.65 3.60 61.76 2
student_41 3.39 13.01 12.47 3.29 17.56 10.16 59.88 2
student_61 5.85 11.56 16.16 5.35 15.95 4.89 59.76 2
student_51 4.08 12.99 18.66 2.92 14.32 6.76 59.73 2
student_45 4.50 11.90 14.51 6.10 16.50 4.86 58.37 2
student_3 3.35 9.67 19.31 5.59 15.76 4.50 58.18 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_54 8.40 9.94 15.43 3.56 12.48 7.29 57.10 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_37 5.61 11.05 11.43 4.56 15.68 6.81 55.14 2
student_40 4.42 8.92 13.01 5.35 16.50 6.93 55.13 2
student_98 4.44 11.00 12.13 6.56 14.37 5.33 53.83 2
student_8 5.13 9.21 11.12 6.46 15.48 6.17 53.57 2
student_9 4.25 11.48 11.12 5.04 15.84 5.71 53.44 2
student_43 2.38 5.53 11.00 4.80 21.52 8.03 53.26 2
student_59 3.85 11.17 12.60 4.50 15.59 3.73 51.44 2
student_12 3.00 12.11 10.61 7.12 15.79 2.28 50.91 2
student_20 5.69 12.33 7.73 4.73 16.17 3.66 50.31 2
student_58 6.10 8.00 12.00 4.08 16.50 2.31 48.99 2
student_11 5.57 9.81 9.43 6.27 13.44 1.60 46.12 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_49 7.29 9.06 5.00 2.30 17.94 3.19 44.78 2
student_26 3.88 10.32 3.00 3.96 18.13 4.72 44.01 2
student_7 5.75 6.89 11.12 2.50 16.43 1.00 43.69 2
student_89 3.73 11.11 3.00 5.18 13.75 5.59 42.36 2
student_50 4.99 10.09 5.00 2.87 16.31 2.89 42.15 2
student_35 2.33 9.74 3.00 6.77 15.09 4.43 41.36 2
student_17 6.62 9.57 4.00 5.61 12.24 2.16 40.20 2
student_75 5.58 8.65 4.00 4.01 15.41 2.29 39.94 2
student_24 3.33 10.66 3.00 3.60 16.29 2.47 39.35 2
student_34 3.38 9.94 3.00 3.66 17.55 0.33 37.86 2
student_48 4.01 5.46 5.00 3.61 18.36 0.35 36.79 2
student_30 4.64 5.69 3.00 6.85 11.84 4.23 36.25 2
student_33 4.94 8.50 3.00 6.06 13.10 0.60 36.20 2
student_92 2.08 8.33 5.00 6.28 8.42 4.61 34.72 2
student_73 2.13 7.53 6.00 3.68 14.00 0.60 33.94 2
student_68 3.41 2.58 8.00 3.67 7.57 3.39 28.62 2
student_10 7.61 2.72 11.07 3.09 0.00 1.95 26.44 2
student_91 3.17 4.23 3.00 3.98 6.65 0.19 21.22 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_85 5.34 13.78 5.00 6.83 25.25 7.85 64.05 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_52 6.77 8.69 18.85 6.52 17.48 4.43 62.74 3
student_46 4.37 12.72 14.51 4.19 22.48 3.72 61.99 3
student_47 8.61 11.27 13.73 6.87 15.75 5.52 61.75 3
student_71 7.00 13.86 8.73 6.33 18.24 6.86 61.02 3
student_29 6.75 12.44 13.71 6.81 14.50 6.38 60.59 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_28 6.75 10.68 13.39 5.95 13.81 7.00 57.58 3
student_14 9.14 12.84 4.00 7.11 19.86 4.50 57.45 3
student_21 8.75 11.51 6.33 5.40 15.73 9.33 57.05 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_57 6.35 9.33 12.60 7.09 16.44 1.60 53.41 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

Column

Četiri klastera

Tablica s četiri klastera
osoba LO_1 LO_2 LO_3 LO_4 LO_5 LO_6 ukupno klaster
student_79 8.33 12.83 25.27 7.31 22.71 11.47 87.92 1
student_22 8.25 13.71 22.97 6.92 23.73 10.58 86.16 1
student_88 6.86 12.82 23.85 6.46 20.94 13.55 84.48 1
student_70 7.13 12.36 22.58 6.84 21.52 10.46 80.89 1
student_86 6.38 12.28 24.20 7.63 17.85 9.79 78.13 1
student_82 6.04 11.44 19.30 6.86 20.52 13.15 77.31 1
student_81 8.38 11.70 18.66 5.35 23.91 7.59 75.59 1
student_78 8.12 12.25 25.27 7.26 13.56 8.88 75.34 1
student_23 6.76 13.02 22.97 6.45 17.05 8.64 74.89 1
student_87 7.25 11.64 24.20 6.86 15.12 8.88 73.95 1
student_53 6.51 13.00 18.97 4.40 17.16 12.65 72.69 1
student_99 4.54 11.93 4.00 4.35 17.75 29.10 71.67 1
student_63 5.17 10.33 24.12 6.13 12.40 11.40 69.55 1
student_56 4.66 13.01 15.86 5.25 17.80 10.60 67.18 1
student_95 5.75 11.84 17.66 5.92 14.84 9.31 65.32 1
student_60 6.51 10.14 14.69 7.10 16.28 9.88 64.60 1
student_1 4.90 10.15 18.73 5.94 16.73 7.19 63.64 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_77 4.03 9.43 25.27 4.78 14.65 3.60 61.76 2
student_41 3.39 13.01 12.47 3.29 17.56 10.16 59.88 2
student_61 5.85 11.56 16.16 5.35 15.95 4.89 59.76 2
student_51 4.08 12.99 18.66 2.92 14.32 6.76 59.73 2
student_45 4.50 11.90 14.51 6.10 16.50 4.86 58.37 2
student_3 3.35 9.67 19.31 5.59 15.76 4.50 58.18 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_54 8.40 9.94 15.43 3.56 12.48 7.29 57.10 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_37 5.61 11.05 11.43 4.56 15.68 6.81 55.14 2
student_40 4.42 8.92 13.01 5.35 16.50 6.93 55.13 2
student_98 4.44 11.00 12.13 6.56 14.37 5.33 53.83 2
student_8 5.13 9.21 11.12 6.46 15.48 6.17 53.57 2
student_9 4.25 11.48 11.12 5.04 15.84 5.71 53.44 2
student_43 2.38 5.53 11.00 4.80 21.52 8.03 53.26 2
student_59 3.85 11.17 12.60 4.50 15.59 3.73 51.44 2
student_12 3.00 12.11 10.61 7.12 15.79 2.28 50.91 2
student_20 5.69 12.33 7.73 4.73 16.17 3.66 50.31 2
student_58 6.10 8.00 12.00 4.08 16.50 2.31 48.99 2
student_11 5.57 9.81 9.43 6.27 13.44 1.60 46.12 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_49 7.29 9.06 5.00 2.30 17.94 3.19 44.78 2
student_26 3.88 10.32 3.00 3.96 18.13 4.72 44.01 2
student_7 5.75 6.89 11.12 2.50 16.43 1.00 43.69 2
student_89 3.73 11.11 3.00 5.18 13.75 5.59 42.36 2
student_50 4.99 10.09 5.00 2.87 16.31 2.89 42.15 2
student_35 2.33 9.74 3.00 6.77 15.09 4.43 41.36 2
student_17 6.62 9.57 4.00 5.61 12.24 2.16 40.20 2
student_75 5.58 8.65 4.00 4.01 15.41 2.29 39.94 2
student_24 3.33 10.66 3.00 3.60 16.29 2.47 39.35 2
student_34 3.38 9.94 3.00 3.66 17.55 0.33 37.86 2
student_48 4.01 5.46 5.00 3.61 18.36 0.35 36.79 2
student_30 4.64 5.69 3.00 6.85 11.84 4.23 36.25 2
student_33 4.94 8.50 3.00 6.06 13.10 0.60 36.20 2
student_92 2.08 8.33 5.00 6.28 8.42 4.61 34.72 2
student_73 2.13 7.53 6.00 3.68 14.00 0.60 33.94 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_85 5.34 13.78 5.00 6.83 25.25 7.85 64.05 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_52 6.77 8.69 18.85 6.52 17.48 4.43 62.74 3
student_46 4.37 12.72 14.51 4.19 22.48 3.72 61.99 3
student_47 8.61 11.27 13.73 6.87 15.75 5.52 61.75 3
student_71 7.00 13.86 8.73 6.33 18.24 6.86 61.02 3
student_29 6.75 12.44 13.71 6.81 14.50 6.38 60.59 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_28 6.75 10.68 13.39 5.95 13.81 7.00 57.58 3
student_14 9.14 12.84 4.00 7.11 19.86 4.50 57.45 3
student_21 8.75 11.51 6.33 5.40 15.73 9.33 57.05 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_57 6.35 9.33 12.60 7.09 16.44 1.60 53.41 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_68 3.41 2.58 8.00 3.67 7.57 3.39 28.62 4
student_10 7.61 2.72 11.07 3.09 0.00 1.95 26.44 4
student_91 3.17 4.23 3.00 3.98 6.65 0.19 21.22 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"
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)

data2 <- data1 %>% 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 %>% mutate(klaster = klasteri3)
data1_cluster4 <- data1 %>% mutate(klaster = klasteri4)

AS <- data1 %>% 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 %>% 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))
```


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.5)
```

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.5) +
  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.5)
```

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.5) +
  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.5) +
  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.5) +
  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)")))
```