---
title: "BDP"
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(flexdashboard)
library(psych)
library(tidyverse)
library(readxl)
library(knitr)
library(kableExtra)
library(corrplot)
library(ClustOfVar)
library(cluster)
library(dendextend)
library(factoextra)
library(circlize)
library(NbClust)
library(gridExtra)

BDP <- read_excel("BDP_po_sudionicima.xlsx") %>% 
  rename(Osoba = `Puno ime`) %>%
  select(-c(3,4,24:30,39,40))
imena <- names(BDP)

BDP <- BDP %>% rename_with(.fn = ~paste0("UTAUT_", which(imena[3:13] == .)), .cols = 3:13) %>%
  rename_with(.fn = ~paste0("LDBDP_", which(imena[14:21] == .)), .cols = 14:21) %>%
  rename_with(.fn = ~paste0("Q", which(imena[22:29] == .)), .cols = 22:29) %>%
  mutate_at(vars(UTAUT_1:LDBDP_8), factor, 
            levels = c("I do not know", "Strongly disagree",
                       "Disagree", "Neither agree nor disagree",
                       "Agree", "Strongly agree")) %>%
  mutate(Q2 = case_when(
  Q2 == "curriculum developers\neducational decision-makers\nresearcher\nteacher" ~ 
    "curriculum developers, educational decision-makers\nresearcher, teacher",
  Q2 == "curriculum developers\neducational decision-makers\ninstructional designer, learning designer\nresearcher\nteacher" ~
    "curriculum developers, educational decision-makers\ninstructional designer, learning designer, researcher, teacher",
  Q2 == "instructional designer, learning designer\nresearcher\nteacher" ~
    "instructional designer, learning designer\nresearcher, teacher",
  Q2 == "curriculum developers\ninstructional designer, learning designer\nresearcher\nteacher" ~
    "curriculum developers, instructional designer\nlearning designer, researcher, teacher",
  Q2 == "instructional designer, learning designer\nresearcher\nteacher\ntechnical expert" ~
    "instructional designer, learning designer\nresearcher, teacher, technical expert",
  Q2 == "educational decision-makers\ninstructional designer, learning designer\nresearcher\nteacher\ntechnical expert" ~
    "educational decision-makers, instructional designer\nlearning designer, researcher, teacher, technical expert",
  .default = Q2
))

kodovi_varijable <- data.frame(varijabla=names(BDP)[-(1:2)], opis=imena[-(1:2)])
likert <- data.frame(Opis = c("I do not know", "Strongly disagree",
                       "Disagree", "Neither agree nor disagree",
                       "Agree", "Strongly agree"),
                    `Numerički kod` = 0:5)
pvalues_stars <- data.frame(interval = c("[0, 0.001)", "[0.001, 0.01)", "[0.01, 0.05)"),
                            oznaka = c('***', '**', '\\*'))

tablica_UTAUT <- BDP %>% select(Osoba, UTAUT_1:UTAUT_11) %>% 
  pivot_longer(UTAUT_1:UTAUT_11, names_to = "varijabla", values_to = "odgovor")
tablica_LDBDP <- BDP %>% select(Osoba, LDBDP_1:LDBDP_8) %>% 
  pivot_longer(LDBDP_1:LDBDP_8, names_to = "varijabla", values_to = "odgovor")

BDP_kor <- BDP %>% select(UTAUT_1:LDBDP_8) %>%
  mutate_all(~case_when(
    . == "I do not know" ~ 0,
    . == "Strongly disagree" ~ 1,
    . == "Disagree" ~ 2,
    . == "Neither agree nor disagree" ~ 3,
    . == "Agree" ~ 4,
    . == "Strongly agree" ~ 5
  ))
kor_holm <- corr.test(BDP_kor, method = "kendall", adjust = "holm")
kor_none <- corr.test(BDP_kor, method = "kendall", adjust = "none")
par_var1 <- as_tibble(kor_holm$ci, rownames = "parovi varijabli") %>%
  select(`parovi varijabli`)
par_var2 <- as_tibble(kor_holm$ci2) %>% 
  select(korelacija = r, `p-value (Holm)` = p.adj, `p-value (bez korekcije)` = p)
par_var <- par_var1 %>% bind_cols(par_var2) %>% arrange(desc(abs(korelacija)))

BDP_klast <- BDP %>% select(UTAUT_1:LDBDP_8)
X_quanti <- PCAmixdata::splitmix(BDP_klast)$X.quanti
X_quali <- PCAmixdata::splitmix(BDP_klast)$X.quali
tree <- hclustvar(X_quanti, X_quali)
stab <- readRDS("stability.rds")
matCR <- as_tibble(stab$matCR) %>% 
  pivot_longer(everything(), names_to = "varijabla", values_to = "vrijednost")

P3 <- cutreevar(tree, 3, matsim = TRUE)
P4 <- cutreevar(tree, 4, matsim = TRUE)
P5 <- cutreevar(tree, 5, matsim = TRUE)
P6 <- cutreevar(tree, 6, matsim = TRUE)
P7 <- cutreevar(tree, 7, matsim = TRUE)

udaljenost <- daisy(BDP_klast, metric = c("gower"))
hc_ward <- hclust(udaljenost, method = "ward.D2")
ward_dend <- as.dendrogram(hc_ward)
ward_dend_color3 <- color_branches(ward_dend, k=3, 
                                   col=c("#00BA38","#F8766D","#619CFF"))
ward_dend_color4 <- color_branches(ward_dend, k=4,
                                   col=c("#7CAE00","#F8766D","#C77CFF","#00BFC4"))
ward_dend_color5 <- color_branches(ward_dend, k=5,
                                   col=c("#A3A500","#E76BF3","#F8766D","#00B0F6","#00BF7D"))

info <- NbClust(diss = udaljenost, distance = NULL, 
                method = "ward.D2", index = "silhouette")
info_tib <- info$All.index %>% as_tibble(rownames = "broj") %>%
  mutate_at(vars(broj), as.numeric)

klasteri3 <- cutree(hc_ward, k = 3)
klasteri4 <- cutree(hc_ward, k = 4)
klasteri5 <- cutree(hc_ward, k = 5)
BDP_cluster3 <- BDP_klast %>% mutate(Cluster = klasteri3)
BDP_cluster4 <- BDP_klast %>% mutate(Cluster = klasteri4)
BDP_cluster5 <- BDP_klast %>% mutate(Cluster = klasteri5)
sil3 <- silhouette(BDP_cluster3$Cluster, udaljenost)
sil4 <- silhouette(BDP_cluster4$Cluster, udaljenost)
sil5 <- silhouette(BDP_cluster5$Cluster, udaljenost)

klaster4_UTAUT <- BDP_cluster4 %>% select(UTAUT_1:UTAUT_11, Cluster) %>% 
  pivot_longer(UTAUT_1:UTAUT_11, names_to = "varijabla", values_to = "odgovor")
klaster4_LDBDP <- BDP_cluster4 %>% select(LDBDP_1:LDBDP_8, Cluster) %>% 
  pivot_longer(LDBDP_1:LDBDP_8, names_to = "varijabla", values_to = "odgovor")

BDP_cluster4_deskriptiva <- BDP %>% select(Q1:Q8) %>% mutate(Cluster = klasteri4)

EFA_model3 <- fa(BDP_kor, nfactors = 3)
EFA_model4 <- fa(BDP_kor, nfactors = 4)
EFA_model5 <- fa(BDP_kor, nfactors = 5)

BDP_aut <- BDP_kor %>% select(UTAUT_1:UTAUT_11)
EFAaut_model2 <- fa(BDP_aut, nfactors = 2)
EFAaut_model3 <- fa(BDP_aut, nfactors = 3)
EFAaut_model4 <- fa(BDP_aut, nfactors = 4)
```

Informacije {data-navmenu="Deskriptiva"}
=======================================================================

Column 1
-----------------------------------------------------------------------

### Opis varijabli

```{r}
kodovi_varijable %>% 
  kbl(caption = "Opis varijabli") %>%
  kable_classic("hover",full_width = F, html_font = "Cambria")
```

Column 2
-----------------------------------------------------------------------

### Likert skala

```{r}
likert %>% 
  kbl(caption = "Kodiranje Likertove skale") %>%
  kable_classic("hover",full_width = F, html_font = "Cambria")
```

### Zvjezdica oznake za p-vrijednosti

```{r}
pvalues_stars %>% 
  kbl(caption = "Oznake za p-vrijednosti ako je $\\alpha=0.05$") %>%
  kable_classic("hover",full_width = F, html_font = "Cambria")
```

UTAUT, LDBDP frekvencije {data-navmenu="Deskriptiva"}
=======================================================================

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

### Frekvencije varijabli UTAUT

```{r}
ggplot(tablica_UTAUT, aes(x = odgovor)) +
  geom_bar(fill="#F8766D", alpha = 0.9) + 
  facet_wrap(vars(fct_relevel(factor(varijabla), "UTAUT_10", "UTAUT_11", after = 9))) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 2.5) +
  coord_flip() + ylim(0,38)
```

### Frekvencije varijabli LDBDP

```{r}
ggplot(tablica_LDBDP, aes(x = odgovor)) +
  geom_bar(fill="#F8766D", alpha = 0.9) + facet_wrap(vars(varijabla)) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 2.5) +
  scale_x_discrete(drop = FALSE) +
  coord_flip() + ylim(0,39)
```

Q1, Q8, Q4, Q5 frekvencije {data-navmenu="Deskriptiva"}
=======================================================================

Column 1
-----------------------------------------------------------------------

### Frekvencije varijable Q1

```{r}
ggplot(BDP, aes(x = Q1)) + geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 5) +
  coord_flip() + ylim(0,15) +
  theme(
    axis.title = element_text(size = 12),
    axis.text = element_text(size = 12)
  )
```

### Frekvencije varijable Q4

```{r}
ggplot(BDP, aes(x = Q4)) + geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 5) +
  coord_flip() + ylim(0,38) +
  theme(
    axis.title = element_text(size = 14),
    axis.text = element_text(size = 14)
  )
```

Column 2
-----------------------------------------------------------------------

### Frekvencije varijable Q8

```{r}
ggplot(BDP, aes(x = Q8)) + geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 5) +
  coord_flip() + ylim(0,18) +
  theme(
    axis.title = element_text(size = 14),
    axis.text = element_text(size = 14)
  )
```

### Frekvencije varijable Q5

```{r}
ggplot(BDP, aes(x = Q5)) + geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 5) +
  coord_flip() + ylim(0,22) +
  theme(
    axis.title = element_text(size = 14),
    axis.text = element_text(size = 14)
  )
```

Q3, Q7 frekvencije {data-navmenu="Deskriptiva"}
=======================================================================

Column 1
-----------------------------------------------------------------------

### Frekvencije varijable Q3

```{r}
ggplot(BDP, aes(x = Q3)) + geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 3.5) +
  coord_flip()
```

Column 2
-----------------------------------------------------------------------

### Frekvencije varijable Q7

```{r}
ggplot(BDP, aes(x = Q7)) + geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 3.5) +
  coord_flip()
```

Q2, Q6 frekvencije {data-navmenu="Deskriptiva"}
=======================================================================

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

### Frekvencije varijable Q2

```{r}
ggplot(BDP, aes(x = Q2)) + geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 3) +
  coord_flip() + ylim(0,15) +
  theme(axis.text.y=element_text(size=rel(0.8)))
```

### Frekvencije varijable Q6

```{r}
ggplot(BDP, aes(x = Q6)) + geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 3) +
  coord_flip() + ylim(0,20) +
  theme(axis.text.y=element_text(size=rel(0.6)))
```

Korelacije {data-navmenu="Deskriptiva"}
=======================================================================

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

### Korelacije (Kendall)

```{r}
corrplot.mixed(kor_none$r, tl.col = "black", tl.srt = 90, tl.pos="lt",
               mar=c(0,0,0.1,0), tl.cex=0.5, number.cex = 0.5)
```

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

### Značajnost (Holm korekcija)

```{r}
corrplot(kor_holm$r, p.mat = kor_holm$p, insig = 'label_sig', sig.level = c(0.001, 0.01, 0.05), 
         type = "upper", diag = FALSE, tl.cex=0.5, tl.col = "black",
         pch.cex = 0.65)
```

### Značajnost (bez korekcije)

```{r}
corrplot(kor_none$r, p.mat = kor_none$p, insig = 'label_sig', sig.level = c(0.001, 0.01, 0.05), 
         type = "upper", diag = FALSE, tl.cex=0.5, tl.col = "black",
         pch.cex = 0.65)
```

### p-vrijednosti (tablica)

```{r}
par_var %>% 
  kbl(caption = "**p-vrijednosti:** tablica je sortirana silazno s obzirom na apsolutne vrijednosti korelacija") %>%
  kable_classic("hover",full_width = F, html_font = "Cambria")
```

Dendrogram {data-navmenu="Klasteriranje varijabli"}
=======================================================================

Column 
-----------------------------------------------------------------------

### Dendrogram

```{r}
plot(tree, cex=0.8)
```

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

### Rand indeksi (mean)

```{r}
plot(stab, main = "Stability of the partitions")
```

### Rand indeksi (boxplot)

```{r}
ggplot(matCR, aes(x = fct_relevel(varijabla, paste0("P",10:18), after = Inf), 
                  y = vrijednost, fill = varijabla)) +
  geom_boxplot() + theme(legend.position = 'none') + xlab("") + ylab("") +
  ggtitle("Dispersion of the adjusted Rand index")
```

3 klastera {data-navmenu="Klasteriranje varijabli"}
=======================================================================

Column 1  
-----------------------------------------------------------------------

### Sličnost varijabli sa sintetičkom varijablom klastera

```{r}
summary(P3)
```

Column 2
-----------------------------------------------------------------------

### Sličnost varijabli unutar klastera {data-height=600}

```{r}
print(P3$sim, digits = 2, max.levels = NULL, width = 100)
```

### Homogenost klastera {data-height=100}

```{r}
print(P3$wss, digits = 3)
```

4 klastera {data-navmenu="Klasteriranje varijabli"}
=======================================================================

Column 1  
-----------------------------------------------------------------------

### Sličnost varijabli sa sintetičkom varijablom klastera

```{r}
summary(P4)
```

Column 2
-----------------------------------------------------------------------

### Sličnost varijabli unutar klastera {data-height=600}

```{r}
print(P4$sim, digits = 2)
```

### Homogenost klastera {data-height=100}

```{r}
print(P4$wss, digits = 3)
```

5 klastera {data-navmenu="Klasteriranje varijabli"}
=======================================================================

Column 1  
-----------------------------------------------------------------------

### Sličnost varijabli sa sintetičkom varijablom klastera

```{r}
summary(P5)
```

Column 2
-----------------------------------------------------------------------

### Sličnost varijabli unutar klastera {data-height=600}

```{r}
print(P5$sim, digits = 2)
```

### Homogenost klastera {data-height=100}

```{r}
print(P5$wss, digits = 3)
```

6 klastera {data-navmenu="Klasteriranje varijabli"}
=======================================================================

Column 1  
-----------------------------------------------------------------------

### Sličnost varijabli sa sintetičkom varijablom klastera

```{r}
summary(P6)
```

Column 2
-----------------------------------------------------------------------

### Sličnost varijabli unutar klastera {data-height=600}

```{r}
print(P6$sim, digits = 2)
```

### Homogenost klastera {data-height=100}

```{r}
print(P6$wss, digits = 3)
```


7 klastera {data-navmenu="Klasteriranje varijabli"}
=======================================================================

Column 1  
-----------------------------------------------------------------------

### Sličnost varijabli sa sintetičkom varijablom klastera

```{r}
summary(P7)
```

Column 2
-----------------------------------------------------------------------

### Sličnost varijabli unutar klastera {data-height=600}

```{r}
print(P7$sim, digits = 2)
```

### Homogenost klastera {data-height=100}

```{r}
print(P7$wss, digits = 3)
```

Dendrogram, Silhouette {data-navmenu="Klasteriranje ispitanika"}
=======================================================================

Column {data-width=500 .tabset .tabset-fade}
-------------------------------------

### Dendrogram (3 klastera)
```{r}
circlize_dendrogram(ward_dend_color3, dend_track_height = 0.8)
```

### Dendrogram (4 klastera)
```{r}
circlize_dendrogram(ward_dend_color4, dend_track_height = 0.8)
```

### Dendrogram (5 klastera)
```{r}
circlize_dendrogram(ward_dend_color5, dend_track_height = 0.8)
```

### Silhouette (summary)

**3 klastera**

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

**4 klastera**

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

**5 klastera**

```{r}
summary(sil5)
```

### Silhouette (broj klastera)

```{r}
ggplot(info_tib,  aes(x=broj, y=value, group = 1)) + 
  geom_point(color = "#0071bf") +
  geom_line(color = "#0071bf") +
  geom_vline(xintercept = info$Best.nc[1], color = "#0071bf", linetype = "dashed") + 
  ggtitle("Optimal number of clusters") +
  labs(x = "Number of clusters", y = "Average silhouette width") +
  scale_x_continuous(breaks = 2:15)
```

Column {data-width=500 .tabset .tabset-fade}
-------------------------------------

### Silhouette (3 klastera)

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

### Silhouette (4 klastera)

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

### Silhouette (5 klastera)

```{r}
fviz_silhouette(sil5, print.summary=FALSE)
```

### Silhouette (summary)

**3 klastera**

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

**4 klastera**

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

**5 klastera**

```{r}
summary(sil5)
```

### Silhouette (broj klastera)

```{r}
ggplot(info_tib,  aes(x=broj, y=value, group = 1)) + 
  geom_point(color = "#0071bf") +
  geom_line(color = "#0071bf") +
  geom_vline(xintercept = info$Best.nc[1], color = "#0071bf", linetype = "dashed") + 
  ggtitle("Optimal number of clusters") +
  labs(x = "Number of clusters", y = "Average silhouette width") +
  scale_x_continuous(breaks = 2:15)
```

Vizualizacija 4 klastera {data-navmenu="Klasteriranje ispitanika"}
=======================================================================

Column {data-width=500 .tabset .tabset-fade}
-------------------------------------

### UTAUT varijable

```{r fig.width=14}
ggplot(klaster4_UTAUT, aes(x = odgovor)) +
  geom_bar(alpha = 0.9, fill="#F8766D") + 
  facet_grid(cols =vars(fct_relevel(factor(varijabla), "UTAUT_10", "UTAUT_11", after = 9)),
             rows = vars(Cluster)) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 2.5) +
  coord_flip() + ylim(0,25)
```

### LDBDP varijable

```{r fig.width=14}
ggplot(klaster4_LDBDP, aes(x = odgovor)) +
  geom_bar(alpha = 0.9, fill="#F8766D") + 
  facet_grid(cols =vars(varijabla), rows = vars(Cluster)) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 2.5) +
  scale_x_discrete(drop = FALSE) + coord_flip() + ylim(0,25)
```

### Q1 Q4

```{r fig.width=12}
slQ1 <- ggplot(BDP_cluster4_deskriptiva, aes(x=Q1)) +
  geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 4) +
  coord_flip() + facet_wrap(vars(Cluster), ncol = 4) +
  scale_y_continuous(breaks = c(0,2,4,6,8), limits = c(0,9)) +
  theme(plot.margin = margin(0,0.2,0.5,0.2,"cm"))
slQ4 <- ggplot(BDP_cluster4_deskriptiva, aes(x=Q4)) +
  geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 4) +
  coord_flip() + ylim(0,16) + facet_wrap(vars(Cluster), ncol = 4) +
  theme(plot.margin = margin(0.5,0.2,0,0.2,"cm"))
grid.arrange(slQ1, slQ4, ncol = 1)
```

### Q5 Q8

```{r fig.width=12}
slQ5 <- ggplot(BDP_cluster4_deskriptiva, aes(x=Q5)) +
  geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 4) +
  coord_flip() + facet_wrap(vars(Cluster), ncol = 4) +
  scale_y_continuous(breaks = c(0,2,4,6,8), limits = c(0,8.5)) +
  theme(plot.margin = margin(0,0.2,0.5,0.2,"cm"))
slQ8 <- ggplot(BDP_cluster4_deskriptiva, aes(x=Q8)) +
  geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 4) +
  coord_flip() + facet_wrap(vars(Cluster), ncol = 4) +
  scale_y_continuous(breaks = c(0,2,4,6,8,10,12), limits = c(0,12)) +
  theme(plot.margin = margin(0.5,0.2,0,0.2,"cm"))
grid.arrange(slQ5, slQ8, ncol = 1)
```

### Q3 Q7

```{r fig.width=12}
slQ3 <- ggplot(BDP_cluster4_deskriptiva, aes(x=Q3)) +
  geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 3) +
  coord_flip() + facet_wrap(vars(Cluster), ncol = 4) +
  theme(plot.margin = margin(0,0.2,0.5,0.2,"cm"))
slQ7 <- ggplot(BDP_cluster4_deskriptiva, aes(x=Q7)) +
  geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 3) +
  coord_flip() + ylim(0,13) + facet_wrap(vars(Cluster), ncol = 4) +
  theme(plot.margin = margin(0.5,0.2,0,0.2,"cm"))
grid.arrange(slQ3, slQ7, ncol = 1)
```

### Q2

```{r fig.width=12}
ggplot(BDP_cluster4_deskriptiva, aes(x=Q2)) +
  geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 3) +
  coord_flip() + facet_wrap(vars(Cluster), ncol = 4) +
  theme(plot.margin = margin(0,0.2,0.5,0.2,"cm"),
        axis.text.y=element_text(size=rel(0.8)))
```

### Q6

```{r fig.width=10}
ggplot(BDP_cluster4_deskriptiva, aes(x=Q6)) +
  geom_bar(fill="#F8766D", alpha = 0.9) +
  geom_text(stat='count', aes(label=..count..), hjust=-0.3, size = 3) +
  coord_flip() + facet_wrap(vars(Cluster), ncol = 4) +
  scale_y_continuous(breaks = c(0,2,4,6,8,10,12), limits = c(0,12)) +
  theme(plot.margin = margin(0,0.2,0.5,0.2,"cm"),
        axis.text.y=element_text(size=rel(0.6)),
        axis.title = element_text(size=rel(0.75)))
```

Unutarnja pouzdanost {data-navmenu="EFA - UTAUT i LDBDP"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### Cronbach alpha

```{r}
psych::alpha(BDP_kor, check.keys = TRUE)
```

Column {data-width=400 .tabset .tabset-fade}
-----------------------------------------------------------------------

### split-half & Kaiser-Meyer-Olkin

#### split-half

```{r}
splitHalf(BDP_kor)
```

#### Kaiser-Meyer-Olkin

```{r}
KMO(BDP_kor)
```

### SCREE plot

```{r warning=FALSE, fig.width=8, fig.height=7}
scree(BDP_kor)
```

EFA model - 3 faktora {data-navmenu="EFA - UTAUT i LDBDP"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### EFA - 3 faktora

```{r}
EFA_model3
```

Column {data-width=400}
-----------------------------------------------------------------------

### Loadings (cutoff = 0.4)

```{r}
print(EFA_model3$loadings, sort=TRUE, cutoff=0.4)
```

Scores - 3 faktora {data-navmenu="EFA - UTAUT i LDBDP"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### Funkcija gustoće

```{r warning=FALSE}
plot(density(EFA_model3$scores, na.rm = TRUE), 
    main = "Factor Scores")
```

Column {data-width=400}
-----------------------------------------------------------------------

### tablica

```{r}
EFA_model3$scores
```

EFA model - 4 faktora {data-navmenu="EFA - UTAUT i LDBDP"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### EFA - 4 faktora

```{r}
EFA_model4
```

Column {data-width=400}
-----------------------------------------------------------------------

### Loadings (cutoff = 0.4)

```{r}
print(EFA_model4$loadings, sort=TRUE, cutoff=0.4)
```

Scores - 4 faktora {data-navmenu="EFA - UTAUT i LDBDP"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### Funkcija gustoće

```{r warning=FALSE}
plot(density(EFA_model4$scores, na.rm = TRUE), 
    main = "Factor Scores")
```

Column {data-width=400}
-----------------------------------------------------------------------

### tablica

```{r}
EFA_model4$scores
```

EFA model - 5 faktora {data-navmenu="EFA - UTAUT i LDBDP"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### EFA - 5 faktora

```{r}
EFA_model5
```

Column {data-width=400}
-----------------------------------------------------------------------

### Loadings (cutoff = 0.4)

```{r}
print(EFA_model5$loadings, sort=TRUE, cutoff=0.4)
```

Scores - 5 faktora {data-navmenu="EFA - UTAUT i LDBDP"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### Funkcija gustoće

```{r warning=FALSE}
plot(density(EFA_model5$scores, na.rm = TRUE), 
    main = "Factor Scores")
```

Column {data-width=400}
-----------------------------------------------------------------------

### tablica

```{r}
EFA_model5$scores
```

Unutarnja pouzdanost {data-navmenu="EFA - UTAUT"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### Cronbach alpha

```{r}
psych::alpha(BDP_aut, check.keys = TRUE)
```

Column {data-width=400 .tabset .tabset-fade}
-----------------------------------------------------------------------

### split-half & Kaiser-Meyer-Olkin

#### split-half

```{r}
splitHalf(BDP_aut)
```

#### Kaiser-Meyer-Olkin

```{r}
KMO(BDP_aut)
```

### SCREE plot

```{r warning=FALSE, fig.width=8, fig.height=7}
scree(BDP_aut)
```

EFA model - 2 faktora {data-navmenu="EFA - UTAUT"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### EFA - 2 faktora

```{r}
EFAaut_model2
```

Column {data-width=400}
-----------------------------------------------------------------------

### Loadings (cutoff = 0.4)

```{r}
print(EFAaut_model2$loadings, sort=TRUE, cutoff=0.4)
```

Scores - 2 faktora {data-navmenu="EFA - UTAUT"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### Funkcija gustoće

```{r warning=FALSE}
plot(density(EFAaut_model2$scores, na.rm = TRUE), 
    main = "Factor Scores")
```

Column {data-width=400}
-----------------------------------------------------------------------

### tablica

```{r}
EFAaut_model2$scores
```

EFA model - 3 faktora {data-navmenu="EFA - UTAUT"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### EFA - 3 faktora

```{r}
EFAaut_model3
```

Column {data-width=400}
-----------------------------------------------------------------------

### Loadings (cutoff = 0.4)

```{r}
print(EFAaut_model3$loadings, sort=TRUE, cutoff=0.4)
```

Scores - 3 faktora {data-navmenu="EFA - UTAUT"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### Funkcija gustoće

```{r warning=FALSE}
plot(density(EFAaut_model3$scores, na.rm = TRUE), 
    main = "Factor Scores")
```

Column {data-width=400}
-----------------------------------------------------------------------

### tablica

```{r}
EFAaut_model3$scores
```

EFA model - 4 faktora {data-navmenu="EFA - UTAUT"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### EFA - 4 faktora

```{r}
EFAaut_model4
```

Column {data-width=400}
-----------------------------------------------------------------------

### Loadings (cutoff = 0.4)

```{r}
print(EFAaut_model4$loadings, sort=TRUE, cutoff=0.4)
```

Scores - 4 faktora {data-navmenu="EFA - UTAUT"}
=======================================================================

Column {data-width=400}
-----------------------------------------------------------------------

### Funkcija gustoće

```{r warning=FALSE}
plot(density(EFAaut_model4$scores, na.rm = TRUE), 
    main = "Factor Scores")
```

Column {data-width=400}
-----------------------------------------------------------------------

### tablica

```{r}
EFAaut_model4$scores
```
