Stršila

Column

Box plot

Column

Summary (sa stršilima)

   STUDENT                I1              I2               I3       
 Length:68          Min.   :0.000   Min.   : 3.775   Min.   :3.310  
 Class :character   1st Qu.:2.330   1st Qu.:11.365   1st Qu.:6.075  
 Mode  :character   Median :2.830   Median :13.188   Median :6.840  
                    Mean   :2.866   Mean   :12.749   Mean   :7.015  
                    3rd Qu.:3.670   3rd Qu.:14.756   3rd Qu.:8.230  
                    Max.   :4.670   Max.   :17.295   Max.   :9.750  
       I4               I5              I6              I7        
 Min.   : 2.000   Min.   :0.000   Min.   : 0.00   Min.   : 0.000  
 1st Qu.: 5.875   1st Qu.:0.500   1st Qu.:12.88   1st Qu.: 5.000  
 Median : 7.000   Median :0.500   Median :14.29   Median : 8.130  
 Mean   : 7.015   Mean   :0.579   Mean   :13.65   Mean   : 7.101  
 3rd Qu.: 8.435   3rd Qu.:0.500   3rd Qu.:15.14   3rd Qu.: 8.830  
 Max.   :11.310   Max.   :2.500   Max.   :18.26   Max.   :12.000  
       I8        
 Min.   : 3.450  
 1st Qu.: 8.845  
 Median :10.030  
 Mean   : 9.513  
 3rd Qu.:10.655  
 Max.   :11.490  

Summary (bez stršila)

   STUDENT                I1              I2               I3       
 Length:55          Min.   :1.000   Min.   : 8.845   Min.   :4.250  
 Class :character   1st Qu.:2.670   1st Qu.:12.193   1st Qu.:6.207  
 Mode  :character   Median :3.000   Median :13.370   Median :6.870  
                    Mean   :3.071   Mean   :13.530   Mean   :7.134  
                    3rd Qu.:3.670   3rd Qu.:15.117   3rd Qu.:8.303  
                    Max.   :4.670   Max.   :17.160   Max.   :9.750  
       I4              I5            I6              I7               I8       
 Min.   : 3.00   Min.   :0.5   Min.   :10.39   Min.   : 3.000   Min.   : 7.81  
 1st Qu.: 6.50   1st Qu.:0.5   1st Qu.:13.71   1st Qu.: 7.190   1st Qu.: 9.32  
 Median : 7.50   Median :0.5   Median :14.45   Median : 8.320   Median :10.21  
 Mean   : 7.44   Mean   :0.5   Mean   :14.36   Mean   : 7.835   Mean   : 9.96  
 3rd Qu.: 8.81   3rd Qu.:0.5   3rd Qu.:15.27   3rd Qu.: 8.920   3rd Qu.:10.67  
 Max.   :11.31   Max.   :0.5   Max.   :18.26   Max.   :12.000   Max.   :11.49  

Dendrogram

Column

Tri klastera

Column

Broj studenata u klasterima

  klaster  n
1       1 21
2       2 23
3       3 11

Silhouette

Column

Silhouette

Column

info

Silhouette of 55 units in 3 clusters from silhouette.default(x = data3_cluster3$klaster, dist = dist(data3)) :
 Cluster sizes and average silhouette widths:
       21        23        11 
0.2215517 0.1209610 0.3083851 
Individual silhouette widths:
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-0.1596  0.1121  0.2075  0.1969  0.2867  0.4473 

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 21
2       2 19
3       3 11
4       4  4

Silhouette

Column

Silhouette

Column

info

Silhouette of 55 units in 4 clusters from silhouette.default(x = data3_cluster4$klaster, dist = dist(data3)) :
 Cluster sizes and average silhouette widths:
       21        19        11         4 
0.2050018 0.1615071 0.2818817 0.3772042 
Individual silhouette widths:
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-0.1001  0.1440  0.2424  0.2179  0.2921  0.4484 

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
STUDENT I1 I2 I3 I4 I5 I6 I7 I8 ukupno klaster
S33 4.67 16.945 7.655 8.00 0.5 18.26 8.92 10.940 75.89 1
S68 4.67 14.725 9.090 7.00 0.5 15.97 11.83 11.465 75.25 1
S50 3.83 17.160 6.655 9.81 0.5 15.14 9.80 10.965 73.86 1
S19 2.83 13.370 9.040 9.31 0.5 15.37 11.50 11.490 73.41 1
S29 2.83 12.200 7.700 10.31 0.5 16.30 12.00 11.440 73.28 1
S27 4.00 16.680 9.180 9.81 0.5 13.94 8.80 10.290 73.20 1
S24 2.67 16.570 9.480 11.31 0.5 13.92 8.32 10.330 73.10 1
S49 4.17 16.625 8.030 7.31 0.5 15.57 10.04 10.645 72.89 1
S62 4.33 13.930 9.450 7.00 0.5 15.75 10.77 10.990 72.72 1
S30 4.67 14.520 8.410 8.31 0.5 15.89 9.56 10.370 72.23 1
S36 3.67 16.305 6.810 10.31 0.5 15.21 8.42 10.445 71.67 1
S39 2.50 15.750 7.710 8.81 0.5 15.34 9.55 10.940 71.10 1
S59 2.67 15.660 6.620 10.81 0.5 14.29 8.22 10.420 69.19 1
S8 2.00 13.815 6.505 9.31 0.5 15.32 9.70 10.860 68.01 1
S1 4.17 16.025 9.150 9.31 0.5 15.04 4.32 9.475 67.99 1
S45 3.50 12.860 7.385 8.00 0.5 14.45 10.00 10.925 67.62 1
S10 2.67 13.370 8.950 7.00 0.5 14.43 8.92 10.680 66.52 1
S44 2.50 14.080 8.245 8.00 0.5 13.52 8.75 10.585 66.18 1
S14 1.67 12.785 8.400 8.00 0.5 16.16 7.85 10.655 66.02 1
S51 1.67 12.185 7.875 7.50 0.5 16.42 9.25 9.530 64.93 1
S37 1.00 12.730 5.680 7.50 0.5 15.66 8.65 10.090 61.81 1
S42 2.67 16.995 6.175 9.81 0.5 13.01 7.64 9.080 65.88 2
S25 3.67 15.365 5.535 10.31 0.5 14.67 6.27 8.860 65.18 2
S9 3.67 12.890 8.700 7.50 0.5 15.71 7.13 8.110 64.21 2
S23 2.83 14.590 7.110 7.00 0.5 15.16 7.75 8.970 63.91 2
S31 3.67 12.560 6.770 8.00 0.5 14.55 8.02 9.280 63.35 2
S3 3.67 15.565 6.470 8.31 0.5 14.21 5.00 9.425 63.15 2
S60 3.17 12.945 9.475 6.00 0.5 14.54 7.40 8.900 62.93 2
S5 3.67 14.010 6.615 6.50 0.5 14.21 7.25 9.835 62.59 2
S64 2.67 13.785 6.500 6.00 0.5 11.87 9.75 11.335 62.41 2
S32 1.00 14.905 8.950 7.50 0.5 10.39 8.18 10.135 61.56 2
S63 3.67 11.415 9.750 7.00 0.5 14.39 5.92 8.275 60.92 2
S35 2.67 14.790 5.420 5.31 0.5 12.18 8.75 10.910 60.53 2
S57 2.67 15.330 6.740 4.00 0.5 11.92 8.65 10.620 60.43 2
S66 2.33 13.290 6.460 7.00 0.5 13.98 7.77 8.410 59.74 2
S20 2.33 13.230 7.205 10.31 0.5 12.92 3.50 9.585 59.58 2
S2 2.67 14.745 6.455 8.00 0.5 14.59 4.56 7.810 59.33 2
S16 2.67 13.220 7.990 5.50 0.5 14.28 3.25 9.970 57.38 2
S53 1.83 12.920 8.015 6.50 0.5 13.70 3.75 9.405 56.62 2
S7 2.67 11.845 8.225 7.00 0.5 12.28 4.18 9.570 56.27 2
S55 2.67 13.845 7.010 4.00 0.5 12.53 4.50 10.355 55.41 2
S61 2.67 15.440 4.470 5.31 0.5 12.75 4.83 8.580 54.55 2
S48 2.33 12.215 6.030 6.50 0.5 12.16 5.00 9.585 54.32 2
S46 2.17 13.950 8.360 3.00 0.5 13.90 3.00 8.180 53.06 2
S47 3.33 12.160 6.240 7.50 0.5 15.01 8.35 11.110 64.20 3
S4 3.00 11.765 6.095 8.81 0.5 14.30 10.08 8.660 63.21 3
S12 4.50 10.860 6.870 7.00 0.5 13.72 8.50 10.380 62.33 3
S18 3.67 9.735 4.955 9.31 0.5 16.07 8.28 9.360 61.88 3
S43 3.17 11.215 5.180 6.50 0.5 14.65 8.75 10.655 60.62 3
S40 3.17 8.845 6.280 6.50 0.5 14.79 7.90 10.915 58.90 3
S13 4.17 9.135 4.480 7.00 0.5 13.08 8.73 9.815 56.91 3
S22 3.67 10.395 4.250 4.50 0.5 14.71 8.35 10.205 56.58 3
S38 3.17 11.705 4.365 5.50 0.5 14.04 8.17 8.800 56.25 3
S58 3.00 10.730 6.090 3.50 0.5 12.64 8.09 10.300 54.85 3
S21 3.33 9.470 5.090 4.00 0.5 15.07 8.48 8.880 54.82 3

Column

Četiri klastera

Tablica s četiri klastera
STUDENT I1 I2 I3 I4 I5 I6 I7 I8 ukupno klaster
S33 4.67 16.945 7.655 8.00 0.5 18.26 8.92 10.940 75.89 1
S68 4.67 14.725 9.090 7.00 0.5 15.97 11.83 11.465 75.25 1
S50 3.83 17.160 6.655 9.81 0.5 15.14 9.80 10.965 73.86 1
S19 2.83 13.370 9.040 9.31 0.5 15.37 11.50 11.490 73.41 1
S29 2.83 12.200 7.700 10.31 0.5 16.30 12.00 11.440 73.28 1
S27 4.00 16.680 9.180 9.81 0.5 13.94 8.80 10.290 73.20 1
S24 2.67 16.570 9.480 11.31 0.5 13.92 8.32 10.330 73.10 1
S49 4.17 16.625 8.030 7.31 0.5 15.57 10.04 10.645 72.89 1
S62 4.33 13.930 9.450 7.00 0.5 15.75 10.77 10.990 72.72 1
S30 4.67 14.520 8.410 8.31 0.5 15.89 9.56 10.370 72.23 1
S36 3.67 16.305 6.810 10.31 0.5 15.21 8.42 10.445 71.67 1
S39 2.50 15.750 7.710 8.81 0.5 15.34 9.55 10.940 71.10 1
S59 2.67 15.660 6.620 10.81 0.5 14.29 8.22 10.420 69.19 1
S8 2.00 13.815 6.505 9.31 0.5 15.32 9.70 10.860 68.01 1
S1 4.17 16.025 9.150 9.31 0.5 15.04 4.32 9.475 67.99 1
S45 3.50 12.860 7.385 8.00 0.5 14.45 10.00 10.925 67.62 1
S10 2.67 13.370 8.950 7.00 0.5 14.43 8.92 10.680 66.52 1
S44 2.50 14.080 8.245 8.00 0.5 13.52 8.75 10.585 66.18 1
S14 1.67 12.785 8.400 8.00 0.5 16.16 7.85 10.655 66.02 1
S51 1.67 12.185 7.875 7.50 0.5 16.42 9.25 9.530 64.93 1
S37 1.00 12.730 5.680 7.50 0.5 15.66 8.65 10.090 61.81 1
S42 2.67 16.995 6.175 9.81 0.5 13.01 7.64 9.080 65.88 2
S25 3.67 15.365 5.535 10.31 0.5 14.67 6.27 8.860 65.18 2
S9 3.67 12.890 8.700 7.50 0.5 15.71 7.13 8.110 64.21 2
S23 2.83 14.590 7.110 7.00 0.5 15.16 7.75 8.970 63.91 2
S31 3.67 12.560 6.770 8.00 0.5 14.55 8.02 9.280 63.35 2
S3 3.67 15.565 6.470 8.31 0.5 14.21 5.00 9.425 63.15 2
S60 3.17 12.945 9.475 6.00 0.5 14.54 7.40 8.900 62.93 2
S5 3.67 14.010 6.615 6.50 0.5 14.21 7.25 9.835 62.59 2
S63 3.67 11.415 9.750 7.00 0.5 14.39 5.92 8.275 60.92 2
S66 2.33 13.290 6.460 7.00 0.5 13.98 7.77 8.410 59.74 2
S20 2.33 13.230 7.205 10.31 0.5 12.92 3.50 9.585 59.58 2
S2 2.67 14.745 6.455 8.00 0.5 14.59 4.56 7.810 59.33 2
S16 2.67 13.220 7.990 5.50 0.5 14.28 3.25 9.970 57.38 2
S53 1.83 12.920 8.015 6.50 0.5 13.70 3.75 9.405 56.62 2
S7 2.67 11.845 8.225 7.00 0.5 12.28 4.18 9.570 56.27 2
S55 2.67 13.845 7.010 4.00 0.5 12.53 4.50 10.355 55.41 2
S61 2.67 15.440 4.470 5.31 0.5 12.75 4.83 8.580 54.55 2
S48 2.33 12.215 6.030 6.50 0.5 12.16 5.00 9.585 54.32 2
S46 2.17 13.950 8.360 3.00 0.5 13.90 3.00 8.180 53.06 2
S47 3.33 12.160 6.240 7.50 0.5 15.01 8.35 11.110 64.20 3
S4 3.00 11.765 6.095 8.81 0.5 14.30 10.08 8.660 63.21 3
S12 4.50 10.860 6.870 7.00 0.5 13.72 8.50 10.380 62.33 3
S18 3.67 9.735 4.955 9.31 0.5 16.07 8.28 9.360 61.88 3
S43 3.17 11.215 5.180 6.50 0.5 14.65 8.75 10.655 60.62 3
S40 3.17 8.845 6.280 6.50 0.5 14.79 7.90 10.915 58.90 3
S13 4.17 9.135 4.480 7.00 0.5 13.08 8.73 9.815 56.91 3
S22 3.67 10.395 4.250 4.50 0.5 14.71 8.35 10.205 56.58 3
S38 3.17 11.705 4.365 5.50 0.5 14.04 8.17 8.800 56.25 3
S58 3.00 10.730 6.090 3.50 0.5 12.64 8.09 10.300 54.85 3
S21 3.33 9.470 5.090 4.00 0.5 15.07 8.48 8.880 54.82 3
S64 2.67 13.785 6.500 6.00 0.5 11.87 9.75 11.335 62.41 4
S32 1.00 14.905 8.950 7.50 0.5 10.39 8.18 10.135 61.56 4
S35 2.67 14.790 5.420 5.31 0.5 12.18 8.75 10.910 60.53 4
S57 2.67 15.330 6.740 4.00 0.5 11.92 8.65 10.620 60.43 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: "EP_APO - 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('EP_APO_Ocjene.xlsx', sheet=1) %>% select(STUDENT:I8)
data1 <- na.omit(data1)
data1_long <- data1 %>% pivot_longer(cols=I1:I8, names_to="Ishod", values_to="Vrijednost")

data1_noOutliers <- data1 %>% 
  filter(
    between(I1, quantile(data1$I1, 0.25) - 1.5*IQR(data1$I1), quantile(data1$I1, 0.75) + 1.5*IQR(data1$I1)),
    between(I2, quantile(data1$I2, 0.25) - 1.5*IQR(data1$I2), quantile(data1$I2, 0.75) + 1.5*IQR(data1$I2)),
    between(I3, quantile(data1$I3, 0.25) - 1.5*IQR(data1$I3), quantile(data1$I3, 0.75) + 1.5*IQR(data1$I3)),
    between(I4, quantile(data1$I4, 0.25) - 1.5*IQR(data1$I4), quantile(data1$I4, 0.75) + 1.5*IQR(data1$I4)),
    between(I5, quantile(data1$I5, 0.25) - 1.5*IQR(data1$I5), quantile(data1$I5, 0.75) + 1.5*IQR(data1$I5)),
    between(I6, quantile(data1$I6, 0.25) - 1.5*IQR(data1$I6), quantile(data1$I6, 0.75) + 1.5*IQR(data1$I6)),
    between(I7, quantile(data1$I7, 0.25) - 1.5*IQR(data1$I7), quantile(data1$I7, 0.75) + 1.5*IQR(data1$I7)),
    between(I8, quantile(data1$I8, 0.25) - 1.5*IQR(data1$I8), quantile(data1$I8, 0.75) + 1.5*IQR(data1$I8))
  )

data2 <- data1_noOutliers %>% select(I1:I8) 
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(I1:I8), mean, na.rm = TRUE)

rez3 <- data1_cluster3 %>% group_by(klaster) %>% 
        summarise_at(vars(I1:I8), mean, na.rm = TRUE) %>% 
        gather(Ishod, Prosjek, I1:I8)
rez3 <- rez3 %>% 
        add_row(klaster=rep(0,8), Ishod=c("I1","I2","I3","I4","I5","I6","I7","I8"), 
                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(I1:I8), mean, na.rm = TRUE) %>% 
        gather(Ishod, Prosjek, I1:I8)
rez4 <- rez4 %>% 
        add_row(klaster=rep(0,8), Ishod=c("I1","I2","I3","I4","I5","I6","I7","I8"), 
                Prosjek=as.numeric(AS))
rez4$klaster <- factor(rez4$klaster)
levels(rez4$klaster) <- c("svi", "1", "2", "3", "4")

bodovi <- c(5,18,12,13,6,19,14,13)

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

viz3 <- data3_cluster3 %>% gather(Ishod, Bodovi, I1:I8)
viz4 <- data3_cluster4 %>% gather(Ishod, Bodovi, I1:I8)

tablica <- data1_noOutliers %>% rowwise() %>% mutate(ukupno = sum(c_across(I1:I8), 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("I1","I2","I3","I4","I5","I6","I7","I8"), 
                 Bodovi=c(5,18,12,13,6,19,14,13),
                 xcor1=rep(2.5,8), xcor2=rep(3,8), ycor=c(5.5,20,13.5,14.5,6.6,21,15.5,14.5))
```

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.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_segment(aes(x=6.6,xend=7.4,y=bodovi[7],yend=bodovi[7]),color="black") +
  geom_segment(aes(x=7.6,xend=8.4,y=bodovi[8],yend=bodovi[8]),color="black") +
  geom_text(x=1, y=5.7, label=bodovi[1], color="black") +
  geom_text(x=2, y=18.7, label=bodovi[2], color="black") +
  geom_text(x=3, y=12.7, label=bodovi[3], color="black") +
  geom_text(x=4, y=13.7, label=bodovi[4], color="black") +
  geom_text(x=5, y=6.7, label=bodovi[5], color="black") +
  geom_text(x=6, y=19.7, label=bodovi[6], color="black") +
  geom_text(x=7, y=14.7, label=bodovi[7], color="black") +
  geom_text(x=8, y=13.7, label=bodovi[8], 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_segment(aes(x=6.6,xend=7.4,y=bodovi[7],yend=bodovi[7]),color="black") +
  geom_segment(aes(x=7.6,xend=8.4,y=bodovi[8],yend=bodovi[8]),color="black") +
  geom_text(x=1, y=5.7, label=bodovi[1], color="black") +
  geom_text(x=2, y=18.7, label=bodovi[2], color="black") +
  geom_text(x=3, y=12.7, label=bodovi[3], color="black") +
  geom_text(x=4, y=13.7, label=bodovi[4], color="black") +
  geom_text(x=5, y=6.7, label=bodovi[5], color="black") +
  geom_text(x=6, y=19.7, label=bodovi[6], color="black") +
  geom_text(x=7, y=14.7, label=bodovi[7], color="black") +
  geom_text(x=8, y=13.7, label=bodovi[8], color="black") +
  geom_text(aes(label=round(Prosjek,2)), position=position_dodge(width=0.9), vjust=-0.5, size=3)
```

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, scales="free") +
  geom_hline(data= hl, aes(yintercept=Bodovi)) +
  geom_text(data = hl, aes(x=xcor1, y=ycor, label=Bodovi), size=3) +
  geom_text(data=rez3, aes(x=klaster, y=Prosjek, label=round(Prosjek,2)), vjust=-0.1, size=3)
```


### Č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, scales="free") +
  geom_hline(data= hl, aes(yintercept=Bodovi)) +
  geom_text(data = hl, aes(x=xcor2, y=ycor, label=Bodovi), size=3) +
  geom_text(data=rez4, aes(x=klaster, y=Prosjek, label=round(Prosjek,2)), vjust=-0.1, size=3)
```

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

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

### Tri klastera

```{r fig.width=9, fig.height=8}
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, 21)) +
  facet_wrap(~Ishod, scales="free",
             labeller=as_labeller(c(I1="I1 (max: 5)", I2="I2 (max: 18)", I3="I3 (max: 12)",
                                  I4="I4 (max: 13)", I5="I5 (max: 6)", I6="I6 (max: 19)",
                                  I7="I7 (max: 14)", I8="I8 (max: 13)")))
```

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

### Četiri klastera

```{r fig.width=9,fig.height=8}
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, 21)) +
  facet_wrap(~Ishod, scales="free",
             labeller=as_labeller(c(I1="I1 (max: 5)", I2="I2 (max: 18)", I3="I3 (max: 12)",
                                  I4="I4 (max: 13)", I5="I5 (max: 6)", I6="I6 (max: 19)",
                                  I7="I7 (max: 14)", I8="I8 (max: 13)")))
```