Dendrogram

Column

Tri klastera

Column

Broj studenata u klasterima

  klaster  n
1       1 57
2       2  7
3       3  4

Silhouette

Column

Silhouette

Column

info

Silhouette of 68 units in 3 clusters from silhouette.default(x = data3_cluster3$klaster, dist = dist(data3)) :
 Cluster sizes and average silhouette widths:
       57         7         4 
0.4443705 0.3570718 0.2142532 
Individual silhouette widths:
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 0.0809  0.4057  0.4327  0.4218  0.4794  0.5640 

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 24
2       2 33
3       3  7
4       4  4

Silhouette

Column

Silhouette

Column

info

Silhouette of 68 units in 4 clusters from silhouette.default(x = data3_cluster4$klaster, dist = dist(data3)) :
 Cluster sizes and average silhouette widths:
       24        33         7         4 
0.1783086 0.1773787 0.2831369 0.1898052 
Individual silhouette widths:
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
-0.1501  0.1111  0.2043  0.1893  0.2889  0.4642 

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.50 18.26 8.92 10.940 75.89 1
S68 4.67 14.725 9.090 7.00 0.50 15.97 11.83 11.465 75.25 1
S50 3.83 17.160 6.655 9.81 0.50 15.14 9.80 10.965 73.86 1
S19 2.83 13.370 9.040 9.31 0.50 15.37 11.50 11.490 73.41 1
S29 2.83 12.200 7.700 10.31 0.50 16.30 12.00 11.440 73.28 1
S27 4.00 16.680 9.180 9.81 0.50 13.94 8.80 10.290 73.20 1
S24 2.67 16.570 9.480 11.31 0.50 13.92 8.32 10.330 73.10 1
S49 4.17 16.625 8.030 7.31 0.50 15.57 10.04 10.645 72.89 1
S62 4.33 13.930 9.450 7.00 0.50 15.75 10.77 10.990 72.72 1
S30 4.67 14.520 8.410 8.31 0.50 15.89 9.56 10.370 72.23 1
S36 3.67 16.305 6.810 10.31 0.50 15.21 8.42 10.445 71.67 1
S39 2.50 15.750 7.710 8.81 0.50 15.34 9.55 10.940 71.10 1
S59 2.67 15.660 6.620 10.81 0.50 14.29 8.22 10.420 69.19 1
S8 2.00 13.815 6.505 9.31 0.50 15.32 9.70 10.860 68.01 1
S1 4.17 16.025 9.150 9.31 0.50 15.04 4.32 9.475 67.99 1
S45 3.50 12.860 7.385 8.00 0.50 14.45 10.00 10.925 67.62 1
S10 2.67 13.370 8.950 7.00 0.50 14.43 8.92 10.680 66.52 1
S44 2.50 14.080 8.245 8.00 0.50 13.52 8.75 10.585 66.18 1
S14 1.67 12.785 8.400 8.00 0.50 16.16 7.85 10.655 66.02 1
S42 2.67 16.995 6.175 9.81 0.50 13.01 7.64 9.080 65.88 1
S25 3.67 15.365 5.535 10.31 0.50 14.67 6.27 8.860 65.18 1
S51 1.67 12.185 7.875 7.50 0.50 16.42 9.25 9.530 64.93 1
S9 3.67 12.890 8.700 7.50 0.50 15.71 7.13 8.110 64.21 1
S47 3.33 12.160 6.240 7.50 0.50 15.01 8.35 11.110 64.20 1
S23 2.83 14.590 7.110 7.00 0.50 15.16 7.75 8.970 63.91 1
S31 3.67 12.560 6.770 8.00 0.50 14.55 8.02 9.280 63.35 1
S4 3.00 11.765 6.095 8.81 0.50 14.30 10.08 8.660 63.21 1
S3 3.67 15.565 6.470 8.31 0.50 14.21 5.00 9.425 63.15 1
S60 3.17 12.945 9.475 6.00 0.50 14.54 7.40 8.900 62.93 1
S5 3.67 14.010 6.615 6.50 0.50 14.21 7.25 9.835 62.59 1
S64 2.67 13.785 6.500 6.00 0.50 11.87 9.75 11.335 62.41 1
S12 4.50 10.860 6.870 7.00 0.50 13.72 8.50 10.380 62.33 1
S18 3.67 9.735 4.955 9.31 0.50 16.07 8.28 9.360 61.88 1
S37 1.00 12.730 5.680 7.50 0.50 15.66 8.65 10.090 61.81 1
S32 1.00 14.905 8.950 7.50 0.50 10.39 8.18 10.135 61.56 1
S63 3.67 11.415 9.750 7.00 0.50 14.39 5.92 8.275 60.92 1
S43 3.17 11.215 5.180 6.50 0.50 14.65 8.75 10.655 60.62 1
S35 2.67 14.790 5.420 5.31 0.50 12.18 8.75 10.910 60.53 1
S57 2.67 15.330 6.740 4.00 0.50 11.92 8.65 10.620 60.43 1
S66 2.33 13.290 6.460 7.00 0.50 13.98 7.77 8.410 59.74 1
S20 2.33 13.230 7.205 10.31 0.50 12.92 3.50 9.585 59.58 1
S2 2.67 14.745 6.455 8.00 0.50 14.59 4.56 7.810 59.33 1
S40 3.17 8.845 6.280 6.50 0.50 14.79 7.90 10.915 58.90 1
S67 3.17 13.985 7.530 2.00 0.50 12.42 7.93 10.185 57.72 1
S16 2.67 13.220 7.990 5.50 0.50 14.28 3.25 9.970 57.38 1
S13 4.17 9.135 4.480 7.00 0.50 13.08 8.73 9.815 56.91 1
S53 1.83 12.920 8.015 6.50 0.50 13.70 3.75 9.405 56.62 1
S22 3.67 10.395 4.250 4.50 0.50 14.71 8.35 10.205 56.58 1
S7 2.67 11.845 8.225 7.00 0.50 12.28 4.18 9.570 56.27 1
S38 3.17 11.705 4.365 5.50 0.50 14.04 8.17 8.800 56.25 1
S55 2.67 13.845 7.010 4.00 0.50 12.53 4.50 10.355 55.41 1
S58 3.00 10.730 6.090 3.50 0.50 12.64 8.09 10.300 54.85 1
S21 3.33 9.470 5.090 4.00 0.50 15.07 8.48 8.880 54.82 1
S61 2.67 15.440 4.470 5.31 0.50 12.75 4.83 8.580 54.55 1
S48 2.33 12.215 6.030 6.50 0.50 12.16 5.00 9.585 54.32 1
S46 2.17 13.950 8.360 3.00 0.50 13.90 3.00 8.180 53.06 1
S34 3.00 10.605 5.010 6.00 0.33 13.50 4.43 7.635 50.51 1
S6 1.67 5.880 7.515 4.50 0.50 11.59 6.92 7.225 45.80 2
S26 3.00 7.395 5.530 3.50 0.00 13.41 0.00 5.205 38.04 2
S52 1.67 10.275 6.610 3.00 0.50 8.44 0.33 7.095 37.92 2
S41 1.00 8.025 7.000 6.50 0.00 8.00 0.00 7.135 37.66 2
S11 1.67 6.590 5.890 6.50 0.50 10.36 1.32 3.450 36.28 2
S28 1.00 6.680 4.770 4.00 0.00 6.00 0.00 6.630 29.08 2
S54 0.00 3.775 3.310 2.50 0.00 0.00 0.00 4.895 14.48 2
S17 3.50 17.295 9.005 7.00 2.50 15.83 10.67 11.420 77.22 3
S56 2.33 13.155 9.630 9.31 2.50 14.67 9.46 10.825 71.88 3
S15 2.67 11.680 7.085 9.00 2.04 13.55 5.15 10.645 61.82 3
S65 1.33 7.445 5.815 4.00 2.50 10.25 5.79 6.740 43.87 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.50 18.26 8.92 10.940 75.89 1
S68 4.67 14.725 9.090 7.00 0.50 15.97 11.83 11.465 75.25 1
S50 3.83 17.160 6.655 9.81 0.50 15.14 9.80 10.965 73.86 1
S19 2.83 13.370 9.040 9.31 0.50 15.37 11.50 11.490 73.41 1
S29 2.83 12.200 7.700 10.31 0.50 16.30 12.00 11.440 73.28 1
S27 4.00 16.680 9.180 9.81 0.50 13.94 8.80 10.290 73.20 1
S24 2.67 16.570 9.480 11.31 0.50 13.92 8.32 10.330 73.10 1
S49 4.17 16.625 8.030 7.31 0.50 15.57 10.04 10.645 72.89 1
S62 4.33 13.930 9.450 7.00 0.50 15.75 10.77 10.990 72.72 1
S30 4.67 14.520 8.410 8.31 0.50 15.89 9.56 10.370 72.23 1
S36 3.67 16.305 6.810 10.31 0.50 15.21 8.42 10.445 71.67 1
S39 2.50 15.750 7.710 8.81 0.50 15.34 9.55 10.940 71.10 1
S59 2.67 15.660 6.620 10.81 0.50 14.29 8.22 10.420 69.19 1
S8 2.00 13.815 6.505 9.31 0.50 15.32 9.70 10.860 68.01 1
S1 4.17 16.025 9.150 9.31 0.50 15.04 4.32 9.475 67.99 1
S10 2.67 13.370 8.950 7.00 0.50 14.43 8.92 10.680 66.52 1
S44 2.50 14.080 8.245 8.00 0.50 13.52 8.75 10.585 66.18 1
S14 1.67 12.785 8.400 8.00 0.50 16.16 7.85 10.655 66.02 1
S42 2.67 16.995 6.175 9.81 0.50 13.01 7.64 9.080 65.88 1
S25 3.67 15.365 5.535 10.31 0.50 14.67 6.27 8.860 65.18 1
S51 1.67 12.185 7.875 7.50 0.50 16.42 9.25 9.530 64.93 1
S3 3.67 15.565 6.470 8.31 0.50 14.21 5.00 9.425 63.15 1
S37 1.00 12.730 5.680 7.50 0.50 15.66 8.65 10.090 61.81 1
S32 1.00 14.905 8.950 7.50 0.50 10.39 8.18 10.135 61.56 1
S45 3.50 12.860 7.385 8.00 0.50 14.45 10.00 10.925 67.62 2
S9 3.67 12.890 8.700 7.50 0.50 15.71 7.13 8.110 64.21 2
S47 3.33 12.160 6.240 7.50 0.50 15.01 8.35 11.110 64.20 2
S23 2.83 14.590 7.110 7.00 0.50 15.16 7.75 8.970 63.91 2
S31 3.67 12.560 6.770 8.00 0.50 14.55 8.02 9.280 63.35 2
S4 3.00 11.765 6.095 8.81 0.50 14.30 10.08 8.660 63.21 2
S60 3.17 12.945 9.475 6.00 0.50 14.54 7.40 8.900 62.93 2
S5 3.67 14.010 6.615 6.50 0.50 14.21 7.25 9.835 62.59 2
S64 2.67 13.785 6.500 6.00 0.50 11.87 9.75 11.335 62.41 2
S12 4.50 10.860 6.870 7.00 0.50 13.72 8.50 10.380 62.33 2
S18 3.67 9.735 4.955 9.31 0.50 16.07 8.28 9.360 61.88 2
S63 3.67 11.415 9.750 7.00 0.50 14.39 5.92 8.275 60.92 2
S43 3.17 11.215 5.180 6.50 0.50 14.65 8.75 10.655 60.62 2
S35 2.67 14.790 5.420 5.31 0.50 12.18 8.75 10.910 60.53 2
S57 2.67 15.330 6.740 4.00 0.50 11.92 8.65 10.620 60.43 2
S66 2.33 13.290 6.460 7.00 0.50 13.98 7.77 8.410 59.74 2
S20 2.33 13.230 7.205 10.31 0.50 12.92 3.50 9.585 59.58 2
S2 2.67 14.745 6.455 8.00 0.50 14.59 4.56 7.810 59.33 2
S40 3.17 8.845 6.280 6.50 0.50 14.79 7.90 10.915 58.90 2
S67 3.17 13.985 7.530 2.00 0.50 12.42 7.93 10.185 57.72 2
S16 2.67 13.220 7.990 5.50 0.50 14.28 3.25 9.970 57.38 2
S13 4.17 9.135 4.480 7.00 0.50 13.08 8.73 9.815 56.91 2
S53 1.83 12.920 8.015 6.50 0.50 13.70 3.75 9.405 56.62 2
S22 3.67 10.395 4.250 4.50 0.50 14.71 8.35 10.205 56.58 2
S7 2.67 11.845 8.225 7.00 0.50 12.28 4.18 9.570 56.27 2
S38 3.17 11.705 4.365 5.50 0.50 14.04 8.17 8.800 56.25 2
S55 2.67 13.845 7.010 4.00 0.50 12.53 4.50 10.355 55.41 2
S58 3.00 10.730 6.090 3.50 0.50 12.64 8.09 10.300 54.85 2
S21 3.33 9.470 5.090 4.00 0.50 15.07 8.48 8.880 54.82 2
S61 2.67 15.440 4.470 5.31 0.50 12.75 4.83 8.580 54.55 2
S48 2.33 12.215 6.030 6.50 0.50 12.16 5.00 9.585 54.32 2
S46 2.17 13.950 8.360 3.00 0.50 13.90 3.00 8.180 53.06 2
S34 3.00 10.605 5.010 6.00 0.33 13.50 4.43 7.635 50.51 2
S6 1.67 5.880 7.515 4.50 0.50 11.59 6.92 7.225 45.80 3
S26 3.00 7.395 5.530 3.50 0.00 13.41 0.00 5.205 38.04 3
S52 1.67 10.275 6.610 3.00 0.50 8.44 0.33 7.095 37.92 3
S41 1.00 8.025 7.000 6.50 0.00 8.00 0.00 7.135 37.66 3
S11 1.67 6.590 5.890 6.50 0.50 10.36 1.32 3.450 36.28 3
S28 1.00 6.680 4.770 4.00 0.00 6.00 0.00 6.630 29.08 3
S54 0.00 3.775 3.310 2.50 0.00 0.00 0.00 4.895 14.48 3
S17 3.50 17.295 9.005 7.00 2.50 15.83 10.67 11.420 77.22 4
S56 2.33 13.155 9.630 9.31 2.50 14.67 9.46 10.825 71.88 4
S15 2.67 11.680 7.085 9.00 2.04 13.55 5.15 10.645 61.82 4
S65 1.33 7.445 5.815 4.00 2.50 10.25 5.79 6.740 43.87 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"
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)

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

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


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)")))
```