---
title: "Zimski semestar 2022/2023"
output: 
  flexdashboard::flex_dashboard:
    orientation: columns
    vertical_layout: fill
    source_code: embed
---

```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(readxl)
library(corrplot)
library(ggsankey)
options(pillar.sigfig = 4)

podaci_MMZI <- read_excel("MMZI 2022_2023.xlsx") %>% drop_na(OCJENA)

MMZI_KOL <- podaci_MMZI %>% 
  unite("student", Ime, Prezime, sep = " ") %>%
  select(c(student:"KOL 3", KP, PROJEKT)) %>%
  pivot_longer(c("KOL 1":"KOL 3", "KP", "PROJEKT"), names_to = "aktivnost", values_to = "bodovi")

korelacije_MMZI <- podaci_MMZI %>% select(c("KOL 1", "KOL 2", "KOL 3", KP, PROJEKT))
testRes_MMZI <- cor.mtest(korelacije_MMZI, conf.level = 0.975)

AS_MED_MMZI <- MMZI_KOL %>% group_by(aktivnost) %>% 
  summarise(mean_value = mean(bodovi,na.rm=TRUE), median_value = median(bodovi,na.rm=TRUE))

podaci_MMZI_sankey<- podaci_MMZI %>%
  replace(is.na(.), 0) %>% select(`KOL 1`:`KOL 3`, PROJEKT) %>%
  mutate(`KOL 1` = case_when(`KOL 1` <= 5 ~ "1", 
                          `KOL 1` <= 10 ~ "2",
                          `KOL 1` <= 15 ~ "3",
                          .default = "4"),
         `KOL 2` = case_when(`KOL 2` <= 5 ~ "1", 
                          `KOL 2` <= 10 ~ "2",
                          `KOL 2` <= 15 ~ "3",
                          .default = "4"),
         `KOL 3` = case_when(`KOL 3` <= 5 ~ "1", 
                          `KOL 3` <= 10 ~ "2",
                          `KOL 3` <= 15 ~ "3",
                          .default = "4"),
         PROJEKT = case_when(PROJEKT <= 5 ~ "1", 
                             PROJEKT <= 10 ~ "2",
                             PROJEKT <= 15 ~ "3",
                             .default = "4")) %>%
  mutate_at(vars(`KOL 1`, `KOL 2`, `KOL 3`, PROJEKT), ~fct_relevel(., c("1","2","3","4")))

st_long_MMZI <- podaci_MMZI_sankey %>% make_long(`KOL 1`, `KOL 2`, `KOL 3`, PROJEKT)

postoci_MMZI <- st_long_MMZI %>% group_by(x, node) %>% summarize(n = n()) %>% 
  ungroup(node) %>% mutate(pct2 = n / sum(n) * 100, pct = round(pct2))
postoci_MMZI[3, "pct"] = 47
postoci_MMZI[12, "pct"] = 1
postoci_MMZI[13, "pct"] = 19

st2_long_MMZI <- st_long_MMZI %>% left_join(postoci_MMZI, by = c("x","node"))

podaci_DSTG <- read_excel("DSTG 2022_2023.xlsx")

DSTG_KOL <- podaci_DSTG %>% 
  unite("student", Ime, Prezime, sep = " ") %>%
  select(c(student:"KOL 2", KP, PROJEKT)) %>%
  pivot_longer(c("KOL 1":"KOL 2", "KP", "PROJEKT"), names_to = "aktivnost", values_to = "bodovi")

korelacije_DSTG <- podaci_DSTG %>% select(c("KOL 1", "KOL 2", KP, PROJEKT))
testRes_DSTG <- cor.mtest(korelacije_DSTG, conf.level = 0.975)

AS_MED_DSTG <- DSTG_KOL %>% group_by(aktivnost) %>% 
  summarise(mean_value = mean(bodovi,na.rm=TRUE), median_value = median(bodovi,na.rm=TRUE))

DSTG_text <- data.frame(
  label_mean = rep("mean", 4),
  label_median = rep("median", 4),
  aktivnost = c("KOL 1", "KOL 2", "KP", "PROJEKT"),
  x_pos = c(23.8,23.8,9.6,37.82),
  bullet_pos = c(23.45,23.45,9.45,37.25)
)

DSTG_blank <- data.frame(
  aktivnost = factor(rep(c("KOL 1", "KOL 2", "KP", "PROJEKT"),each=2)),
  x = c(0,25,0,25,0,10,0,40),
  y = 0
)

podaci_DSTG_sankey<- podaci_DSTG %>%
  replace(is.na(.), 0) %>% select(`KOL 1`:`KOL 2`, PROJEKT) %>%
  mutate(`KOL 1` = case_when(`KOL 1` <= 6.25 ~ "1", 
                             `KOL 1` <= 12.5 ~ "2",
                             `KOL 1` <= 18.75 ~ "3",
                             .default = "4"),
         `KOL 2` = case_when(`KOL 2` <= 6.25 ~ "1", 
                             `KOL 2` <= 12.5 ~ "2",
                             `KOL 2` <= 18.75 ~ "3",
                             .default = "4"),
         PROJEKT = case_when(PROJEKT <= 10 ~ "1", 
                             PROJEKT <= 20 ~ "2",
                             PROJEKT <= 30 ~ "3",
                             .default = "4")) %>%
  mutate_at(vars(`KOL 1`, `KOL 2`, PROJEKT), ~fct_relevel(., c("1","2","3","4")))

st_long_DSTG <- podaci_DSTG_sankey %>% make_long(`KOL 1`, `KOL 2`, PROJEKT)

postoci_DSTG <- st_long_DSTG %>% group_by(x, node) %>% summarize(n = n()) %>% 
  ungroup(node) %>% mutate(pct2 = n / sum(n) * 100, pct = round(pct2))
postoci_DSTG[6, "pct"] <- 6
postoci_DSTG[10, "pct"] <- 14

st2_long_DSTG <- st_long_DSTG %>% left_join(postoci_DSTG, by = c("x","node"))

podaci_MAT1 <- read_excel("MAT1 2022_2023.xlsx")

MAT1_KOL <- podaci_MAT1 %>% 
  unite("student", Ime, Prezime, sep = " ") %>%
  select(c(student:"KOL 3", KP, DZ, ESEJ)) %>%
  pivot_longer(c("KOL 1":"KOL 3", "KP", "DZ", "ESEJ"), names_to = "aktivnost", values_to = "bodovi") %>%
  mutate(aktivnost = factor(aktivnost, levels=c('KOL 1', 'KOL 2', 'KOL 3', 'KP', 'DZ', 'ESEJ')))

korelacije_MAT1 <- podaci_MAT1 %>% select(c("KOL 1", "KOL 2", "KOL 3", KP, DZ, ESEJ))
testRes_MAT1 <- cor.mtest(korelacije_MAT1, conf.level = 0.975)

AS_MED_MAT1 <- MAT1_KOL %>% group_by(aktivnost) %>% 
  summarise(mean_value = mean(bodovi,na.rm=TRUE), median_value = median(bodovi,na.rm=TRUE))

MAT1_text <- data.frame(
  label_mean = rep("mean", 6),
  label_median = rep("median", 6),
  aktivnost = factor(c("KOL 1", "KOL 2", "KOL 3", "KP", "DZ", "ESEJ")),
  x_pos = c(18, 18, 18, 18, 9.25, 9.25),
  bullet_pos = c(17.5, 17.5, 17.5, 17.5, 9, 9)
)

MAT1_blank <- data.frame(
  aktivnost = factor(rep(c("KOL 1", "KOL 2", "KOL 3", "KP", "DZ", "ESEJ"),each=2)),
  x = c(0,20,0,20,0,20,0,20,0,10,0,10),
  y = 0
)

podaci_MAT1_sankey<- podaci_MAT1 %>%
  replace(is.na(.), 0) %>% select(`KOL 1`:`KOL 3`, ESEJ) %>%
  mutate(`KOL 1` = case_when(`KOL 1` <= 5 ~ "1", 
                             `KOL 1` <= 10 ~ "2",
                             `KOL 1` <= 15 ~ "3",
                             .default = "4"),
         `KOL 2` = case_when(`KOL 2` <= 5 ~ "1", 
                             `KOL 2` <= 10 ~ "2",
                             `KOL 2` <= 15 ~ "3",
                             .default = "4"),
         `KOL 3` = case_when(`KOL 3` <= 5 ~ "1", 
                             `KOL 3` <= 10 ~ "2",
                             `KOL 3` <= 15 ~ "3",
                             .default = "4"),
         ESEJ = case_when(ESEJ <= 2.5 ~ "1", 
                             ESEJ <= 5 ~ "2",
                             ESEJ <= 7.5 ~ "3",
                             .default = "4")) %>%
  mutate_at(vars(`KOL 1`, `KOL 2`, `KOL 3`, ESEJ), ~fct_relevel(., c("1","2","3","4")))

st_long_MAT1 <- podaci_MAT1_sankey %>% make_long(`KOL 1`, `KOL 2`, `KOL 3`, ESEJ)

postoci_MAT1 <- st_long_MAT1 %>% group_by(x, node) %>% summarize(n = n()) %>% 
  ungroup(node) %>% mutate(pct2 = n / sum(n) * 100, pct = round(pct2))
postoci_MAT1[12, "pct"] <- 1
postoci_MAT1[14, "pct"] <- 24

st2_long_MAT1 <- st_long_MAT1 %>% left_join(postoci_MAT1, by = c("x","node"))

podaci_MZE1 <- read_excel("MZE1 2022_2023.xlsx")

MZE1_KOL <- podaci_MZE1 %>% 
  unite("student", Ime, Prezime, sep = " ") %>%
  select(c(student:"KOL 3", KP, DZ, USMENI)) %>%
  pivot_longer(c("KOL 1":"KOL 3", "KP", "DZ", "USMENI"), names_to = "aktivnost", values_to = "bodovi") %>%
  mutate(aktivnost = factor(aktivnost, levels=c('KOL 1', 'KOL 2', 'KOL 3', 'KP', 'DZ', 'USMENI')))

korelacije_MZE1 <- podaci_MZE1 %>% select(c("KOL 1", "KOL 2", "KOL 3", KP, DZ, USMENI))
testRes_MZE1 <- cor.mtest(korelacije_MZE1, conf.level = 0.975)

AS_MED_MZE1 <- MZE1_KOL %>% group_by(aktivnost) %>% 
  summarise(mean_value = mean(bodovi,na.rm=TRUE), median_value = median(bodovi,na.rm=TRUE))

MZE1_text <- data.frame(
  label_mean = rep("mean", 6),
  label_median = rep("median", 6),
  aktivnost = factor(c("KOL 1", "KOL 2", "KOL 3", "KP", "DZ", "USMENI")),
  x_pos = c(18.2, 18.2, 18.2, 9.3, 18.2, 9.25),
  bullet_pos = c(17.7, 17.7, 17.7, 9, 17.7, 9)
)

MZE1_blank <- data.frame(
  aktivnost = factor(rep(c("KOL 1", "KOL 2", "KOL 3", "KP", "DZ", "USMENI"),each=2)),
  x = c(0,20,0,20,0,20,0,10,0,20,0,10),
  y = 0
)

podaci_MZE1_sankey<- podaci_MZE1 %>%
  replace(is.na(.), 0) %>% select(`KOL 1`:`KOL 3`) %>%
  mutate(`KOL 1` = case_when(`KOL 1` <= 5 ~ "1", 
                             `KOL 1` <= 10 ~ "2",
                             `KOL 1` <= 15 ~ "3",
                             .default = "4"),
         `KOL 2` = case_when(`KOL 2` <= 5 ~ "1", 
                             `KOL 2` <= 10 ~ "2",
                             `KOL 2` <= 15 ~ "3",
                             .default = "4"),
         `KOL 3` = case_when(`KOL 3` <= 5 ~ "1", 
                             `KOL 3` <= 10 ~ "2",
                             `KOL 3` <= 15 ~ "3",
                             .default = "4")) %>%
  mutate_at(vars(`KOL 1`, `KOL 2`, `KOL 3`), ~fct_relevel(., c("1","2","3","4")))

st_long_MZE1 <- podaci_MZE1_sankey %>% make_long(`KOL 1`, `KOL 2`, `KOL 3`)

postoci_MZE1 <- st_long_MZE1 %>% group_by(x, node) %>% summarize(n = n()) %>% 
  ungroup(node) %>% mutate(pct2 = n / sum(n) * 100, pct = round(pct2))

st2_long_MZE1 <- st_long_MZE1 %>% left_join(postoci_MZE1, by = c("x","node"))
```

Gustoće {data-navmenu="MMZI"}
=======================================================================

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

### Funkcije gustoća po aktivnostima

```{r warning=FALSE, fig.width=17, fig.height=9}
ggplot(MMZI_KOL, aes(x=bodovi)) + 
  geom_histogram(aes(y=..density..), binwidth = 1, boundary=1, 
                 color="#ec8ae5", fill="#48d09b", alpha=0.7) +
  geom_density(alpha=.2, fill="yellow") +
  scale_x_continuous(name = "bodovi", breaks = seq(0,20,5), limits = c(0,20)) + 
  scale_y_continuous(limits = c(0, 0.2)) + guides(color = "none", fill = "none") +
  facet_wrap(vars(aktivnost)) +
  geom_vline(data=AS_MED_MMZI, aes(xintercept=mean_value), color="blue", 
             linetype="dashed", size=0.5, alpha=0.6) +
  geom_vline(data=AS_MED_MMZI, aes(xintercept=median_value), color="red", 
             linetype="dashed", size=0.5, alpha=0.6) + 
  annotate(geom="point", x=17, y=0.18, size=2, shape=21, fill="red",color="red") +
  annotate(geom="text", x=17.4, y=0.181, label="median",size=4,hjust=0) +
  annotate(geom="point", x=17, y=0.195, size=2, shape=21, fill="blue",color="blue") +
  annotate(geom="text", x=17.4, y=0.196, label="mean",size=4,hjust=0) +
  geom_rug(alpha=0.3)
```

Column {data-width=150}
-----------------------------------------------------------------------

### Brojčane vrijednosti

```{r warning=FALSE}
MMZI_KOL %>% group_by(aktivnost) %>%
  summarize(BROJ = sum(!is.na(bodovi)),
            MEAN = round(mean(bodovi, na.rm = TRUE), 2), 
            MEDIAN = median(bodovi, na.rm = TRUE), 
            MIN = min(bodovi, na.rm = TRUE),
            MAX = max(bodovi, na.rm = TRUE)) %>% knitr::kable()
```

Violine {data-navmenu="MMZI"}
=======================================================================

```{r warning=FALSE, fig.width=17, fig.height=9}
ggplot(MMZI_KOL, aes(x=aktivnost, y=bodovi, fill=aktivnost)) +
  geom_dotplot(binaxis='y', stackdir='center', fill='black', dotsize=0.25, alpha=0.3, binwidth = 0.8) +
  geom_violin(trim=F, alpha=0.3) + geom_boxplot(width=0.05, alpha=1) + xlab('') +
  theme(axis.text.x=element_text(size=11), axis.text.y=element_text(size=11), legend.position='none')
```

Ukupni bodovi {data-navmenu="MMZI"}
=======================================================================

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

### Frekvencije ukupnih bodova

```{r warning=FALSE, fig.width=10, fig.height=5}
ggplot(podaci_MMZI, aes(x=UKUPNO)) + 
  geom_histogram(binwidth = 1, boundary=1, color="#ec8ae5", fill="#48d09b", alpha=0.7) +
  scale_x_continuous(name = "ukupni bodovi", breaks = seq(0,100,5), limits = c(0,100)) + 
  scale_y_continuous(name = "broj studenata", breaks = seq(0,16)) +
  theme(panel.grid.minor = element_blank())
```

### Ocjene

```{r warning=FALSE, fig.width=10, fig.height=5}
ggplot(podaci_MMZI, aes(x=factor(OCJENA))) +
  geom_bar(width=0.7, fill="steelblue") +
  geom_text(stat="count", aes(label=..count..), vjust=-0.5, nudge_x = -0.2, size = 5) +
  geom_text(aes( label = sprintf('(%s)', scales::percent(..prop..)), group = 1), stat= "count", 
            vjust = -.5, nudge_x = 0.15, size = 5) +
  scale_x_discrete(name = "Ocjena") +
  scale_y_continuous(name = "broj studenata", breaks = seq(0,120,10), limits = c(0,120)) +
  theme(panel.grid.major.x = element_blank())
```

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

### Distribucija bodova

```{r warning=FALSE, fig.width=10, fig.height=7}
ggplot(podaci_MMZI, aes(x=UKUPNO)) + 
  geom_histogram(aes(y=..density..), color="#ec8ae5", fill="#48d09b", alpha=0.5, 
                 breaks = c(0,20,50,61,75,91,100)) +
  geom_vline(aes(xintercept=mean(UKUPNO)),color="blue", linetype="dashed", size=0.5, alpha=0.6) +
  geom_vline(aes(xintercept=median(UKUPNO)),color="red", linetype="dashed", size=0.5, alpha=0.6) +
  annotate(geom="point", x=90, y=0.035, size=2, shape=21, fill="red",color="red") +
  annotate(geom="text", x=91, y=0.035, label="median",size=3.5,hjust=0) +
  annotate(geom="point", x=90, y=0.033, size=2, shape=21, fill="blue",color="blue") +
  annotate(geom="text", x=91, y=0.033, label="mean",size=3.5,hjust=0) +
  geom_density(alpha=.2, fill="yellow") +
  geom_rug(alpha=0.3) +
  scale_x_continuous(name = "ukupni bodovi", breaks = seq(0,100,5), limits = c(0,100)) +
  theme(panel.grid.minor.x = element_blank())
```

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

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

### Korelacije

```{r warning=FALSE, fig.width=10, fig.height=7}
corrplot(round(cor(korelacije_MMZI, use = "pairwise.complete.obs"), 2), type = "lower",
         diag=FALSE, addCoef.col = 'black', tl.srt = 45)
```

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

### p-vrijednosti korelacija

```{r warning=FALSE, fig.width=10, fig.height=7}
corrplot(round(cor(korelacije_MMZI, use = "pairwise.complete.obs"), 2), type = "lower",
         diag=FALSE, tl.srt = 45, p.mat = testRes_MMZI$p, insig = 'p-value', sig.level = -1)
```

Sankey {data-navmenu="MMZI"}
=======================================================================

```{r warning=FALSE}
ggplot(st2_long_MMZI, aes(x = x, next_x = next_x, node = node, next_node = next_node,
                     fill = factor(node),
                     label = paste0(node, ' (', pct, '%)'))) +
  geom_sankey(flow.alpha = 0.5, node.color = "black", show.legend = FALSE) +
  geom_sankey_label(size = 3, color = "black", fill= "white", hjust = -0.3) +
  theme_bw() + theme_sankey(base_size = 16) +
  theme(axis.title = element_blank(), axis.text.y = element_blank(), 
        axis.ticks = element_blank(), panel.grid = element_blank())
```

Gustoće {data-navmenu="DSTG"}
=======================================================================

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

### Funkcije gustoća po aktivnostima

```{r warning=FALSE, fig.width=17, fig.height=9}
ggplot(DSTG_KOL, aes(x=bodovi)) + 
  geom_histogram(aes(y=..density..), binwidth = 1, boundary=1,
                 color="#ec8ae5", fill="#48d09b", alpha=0.7) +
  geom_density(alpha=.2, fill="yellow") + geom_blank(data=DSTG_blank, aes(x=x,y=y)) +
  scale_x_continuous(name = "bodovi") + 
  scale_y_continuous(limits = c(0, 0.2)) + guides(color = "none", fill = "none") +
  facet_wrap(vars(aktivnost), scales = "free_x") +
  geom_vline(data=AS_MED_DSTG, aes(xintercept=mean_value), color="blue", 
             linetype="dashed", size=0.5, alpha=0.6) +
  geom_vline(data=AS_MED_DSTG, aes(xintercept=median_value), color="red", 
             linetype="dashed", size=0.5, alpha=0.6) +
  geom_text(data = DSTG_text, mapping = aes(label = "\u2022", x = bullet_pos), 
            y = 0.185, color = "blue", size = 9) +
  geom_text(data = DSTG_text, mapping = aes(label = label_mean, x = x_pos), 
            y = 0.185, hjust = 0) +
  geom_text(data = DSTG_text, mapping = aes(label = "\u2022", x = bullet_pos), 
            y = 0.168, color = "red", size = 9) +
  geom_text(data = DSTG_text, mapping = aes(label = label_median, x = x_pos), 
            y = 0.168, hjust = 0) +
  geom_rug(alpha=0.3)
```

Column {data-width=150}
-----------------------------------------------------------------------

### Brojčane vrijednosti

```{r warning=FALSE}
DSTG_KOL %>% group_by(aktivnost) %>%
  summarize(BROJ = sum(!is.na(bodovi)),
            MEAN = round(mean(bodovi, na.rm = TRUE), 2),
            MEDIAN = median(bodovi, na.rm = TRUE), 
            MIN = min(bodovi, na.rm = TRUE),
            MAX = max(bodovi, na.rm = TRUE)) %>% knitr::kable()
```

Violine {data-navmenu="DSTG"}
=======================================================================

```{r warning=FALSE, fig.width=17, fig.height=9}
ggplot(DSTG_KOL, aes(x=aktivnost, y=bodovi, fill=aktivnost)) +
  geom_dotplot(binaxis='y', stackdir='center', fill='black', alpha=0.3, dostsize = 1) +
  geom_violin(trim=F, alpha=0.3) + geom_boxplot(width=0.05, alpha=0.8) + xlab('') +
  theme(axis.text.x=element_text(size=11), axis.text.y=element_text(size=11), legend.position='none') +
  facet_wrap(vars(aktivnost), scale = "free") +
  theme(axis.text.x=element_blank(), axis.ticks.x=element_blank())
```

Ukupni bodovi {data-navmenu="DSTG"}
=======================================================================

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

### Frekvencije ukupnih bodova

```{r warning=FALSE, fig.width=10, fig.height=5}
ggplot(podaci_DSTG, aes(x=UKUPNO)) + 
  geom_histogram(binwidth = 1, boundary=1, color="#ec8ae5", fill="#48d09b", alpha=0.7) +
  scale_x_continuous(name = "ukupni bodovi", breaks = seq(0,100,5), limits = c(0,100)) + 
  scale_y_continuous(name = "broj studenata", breaks = seq(0,16)) +
  theme(panel.grid.minor = element_blank())
```

### Ocjene

```{r warning=FALSE, fig.width=10, fig.height=5}
ggplot(podaci_DSTG, aes(x=factor(OCJENA))) +
  geom_bar(width=0.7, fill="steelblue") +
  geom_text(stat="count", aes(label=..count..), vjust=-0.5, nudge_x = -0.2, size = 5) +
  geom_text(aes( label = sprintf('(%s)', scales::percent(..prop..)), group = 1), stat= "count", 
            vjust = -.5, nudge_x = 0.15, size = 5) +
  scale_x_discrete(name = "Ocjena") +
  scale_y_continuous(name = "broj studenata", breaks = seq(0,60,10), limits = c(0,60)) +
  theme(panel.grid.major.x = element_blank())
```

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

### Distribucija bodova

```{r warning=FALSE, fig.width=10, fig.height=7}
ggplot(podaci_DSTG, aes(x=UKUPNO)) + 
  geom_histogram(aes(y=..density..), color="#ec8ae5", fill="#48d09b", alpha=0.5, 
                 breaks = c(0,20,50,61,75,91,100)) +
  geom_vline(aes(xintercept=mean(UKUPNO)),color="blue", linetype="dashed", size=0.5, alpha=0.6) +
  geom_vline(aes(xintercept=median(UKUPNO)),color="red", linetype="dashed", size=0.5, alpha=0.6) +
  annotate(geom="point", x=90, y=0.035, size=2, shape=21, fill="red",color="red") +
  annotate(geom="text", x=91, y=0.035, label="median",size=3.5,hjust=0) +
  annotate(geom="point", x=90, y=0.033, size=2, shape=21, fill="blue",color="blue") +
  annotate(geom="text", x=91, y=0.033, label="mean",size=3.5,hjust=0) +
  geom_density(alpha=.2, fill="yellow") +
  geom_rug(alpha=0.3) +
  scale_x_continuous(name = "ukupni bodovi", breaks = seq(0,100,5), limits = c(0,100)) +
  theme(panel.grid.minor.x = element_blank())
```

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

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

### Korelacije

```{r warning=FALSE, fig.width=10, fig.height=7}
corrplot(round(cor(korelacije_DSTG, use = "pairwise.complete.obs"), 2), type = "lower",
         diag=FALSE, addCoef.col = 'black', tl.srt = 45)
```

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

### p-vrijednosti korelacija

```{r warning=FALSE, fig.width=10, fig.height=7}
corrplot(round(cor(korelacije_DSTG, use = "pairwise.complete.obs"), 2), type = "lower",
         diag=FALSE, tl.srt = 45, p.mat = testRes_DSTG$p, insig = 'p-value', sig.level = -1)
```

Sankey {data-navmenu="DSTG"}
=======================================================================

```{r warning=FALSE}
ggplot(st2_long_DSTG, aes(x = x, next_x = next_x, node = node, next_node = next_node,
                     fill = factor(node),
                     label = paste0(node, ' (', pct, '%)'))) +
  geom_sankey(flow.alpha = 0.5, node.color = "black", show.legend = FALSE) +
  geom_sankey_label(size = 3, color = "black", fill= "white", hjust = -0.35) +
  theme_bw() + theme_sankey(base_size = 16) +
  theme(axis.title = element_blank(), axis.text.y = element_blank(), 
        axis.ticks = element_blank(), panel.grid = element_blank())
```

Gustoće {data-navmenu="MAT 1"}
=======================================================================

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

### Funkcije gustoća po aktivnostima

```{r warning=FALSE, fig.width=17, fig.height=9}
ggplot(MAT1_KOL, aes(x=bodovi)) + 
  geom_histogram(aes(y=..density..), binwidth = 1, boundary=1, 
                 color="#ec8ae5", fill="#48d09b", alpha=0.7) +
  geom_density(alpha=.2, fill="yellow") + geom_blank(data=MAT1_blank, aes(x=x,y=y)) +
  scale_x_continuous(name = "bodovi") + 
  scale_y_continuous(limits = c(0, 0.25)) + guides(color = "none", fill = "none") +
  facet_wrap(vars(aktivnost), scales = "free_x") +
  geom_vline(data=AS_MED_MAT1, aes(xintercept=mean_value), color="blue", 
             linetype="dashed", size=0.5, alpha=0.6) +
  geom_vline(data=AS_MED_MAT1, aes(xintercept=median_value), color="red", 
             linetype="dashed", size=0.5, alpha=0.6) +
  geom_text(data = MAT1_text, mapping = aes(label = "\u2022", x = bullet_pos), 
            y = 0.24, color = "blue", size = 9) + 
  geom_text(data = MAT1_text, mapping = aes(label = label_mean, x = x_pos), 
            y = 0.24, hjust = 0) +
  geom_text(data = MAT1_text, mapping = aes(label = "\u2022", x = bullet_pos), 
            y = 0.22, color = "red", size = 9) +
  geom_text(data = MAT1_text, mapping = aes(label = label_median, x = x_pos), 
            y = 0.22, hjust = 0) +
  geom_rug(alpha=0.3)
```

Column {data-width=150}
-----------------------------------------------------------------------

### Brojčane vrijednosti

```{r warning=FALSE}
MAT1_KOL %>% group_by(aktivnost) %>%
  summarize(BROJ = sum(!is.na(bodovi)),
            MEAN = round(mean(bodovi, na.rm = TRUE), 2),
            MEDIAN = median(bodovi, na.rm = TRUE), 
            MIN = min(bodovi, na.rm = TRUE),
            MAX = max(bodovi, na.rm = TRUE)) %>% knitr::kable()
```

Violine {data-navmenu="MAT 1"}
=======================================================================

```{r warning=FALSE, fig.width=17, fig.height=9}
ggplot(MAT1_KOL, aes(x=aktivnost, y=bodovi, fill=aktivnost)) +
  geom_dotplot(binaxis='y', stackdir='center', fill='black', alpha=0.3, dostsize = 0.2) +
  geom_violin(trim=F, alpha=0.3) + geom_boxplot(width=0.05, alpha=0.8) + xlab('') +
  theme(axis.text.x=element_text(size=11), axis.text.y=element_text(size=11), legend.position='none') +
  facet_wrap(vars(aktivnost), scale = "free") +
  theme(axis.text.x=element_blank(), axis.ticks.x=element_blank())
```

Ukupni bodovi {data-navmenu="MAT 1"}
=======================================================================

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

### Frekvencije ukupnih bodova

```{r warning=FALSE, fig.width=10, fig.height=5}
ggplot(podaci_MAT1, aes(x=UKUPNO)) + 
  geom_histogram(binwidth = 1, boundary=1, color="#ec8ae5", fill="#48d09b", alpha=0.7) +
  scale_x_continuous(name = "ukupni bodovi", breaks = seq(0,100,5), limits = c(0,100)) + 
  scale_y_continuous(name = "broj studenata", breaks = seq(0,20)) +
  theme(panel.grid.minor = element_blank())
```

### Ocjene

```{r warning=FALSE, fig.width=10, fig.height=5}
ggplot(podaci_MAT1, aes(x=factor(OCJENA))) +
  geom_bar(width=0.7, fill="steelblue") +
  geom_text(stat="count", aes(label=..count..), vjust=-0.5, nudge_x = -0.2, size = 5) +
  geom_text(aes( label = sprintf('(%s)', scales::percent(..prop..)), group = 1), stat= "count", 
            vjust = -.5, nudge_x = 0.15, size = 5) +
  scale_x_discrete(name = "Ocjena") +
  scale_y_continuous(name = "broj studenata", breaks = seq(0,200,25), limits = c(0,200)) +
  theme(panel.grid.major.x = element_blank())
```

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

### Distribucija bodova

```{r warning=FALSE, fig.width=10, fig.height=7}
ggplot(podaci_MAT1, aes(x=UKUPNO)) + 
  geom_histogram(aes(y=..density..), color="#ec8ae5", fill="#48d09b", alpha=0.5, 
                 breaks = c(0,20,50,61,75,91,100)) +
  geom_vline(aes(xintercept=mean(UKUPNO)),color="blue", linetype="dashed", size=0.5, alpha=0.6) +
  geom_vline(aes(xintercept=median(UKUPNO)),color="red", linetype="dashed", size=0.5, alpha=0.6) +
  annotate(geom="point", x=90, y=0.035, size=2, shape=21, fill="red",color="red") +
  annotate(geom="text", x=91, y=0.035, label="median",size=3.5,hjust=0) +
  annotate(geom="point", x=90, y=0.033, size=2, shape=21, fill="blue",color="blue") +
  annotate(geom="text", x=91, y=0.033, label="mean",size=3.5,hjust=0) +
  geom_density(alpha=.2, fill="yellow") +
  geom_rug(alpha=0.3) +
  scale_x_continuous(name = "ukupni bodovi", breaks = seq(0,100,5), limits = c(0,100)) +
  theme(panel.grid.minor.x = element_blank())
```

Korelacije {data-navmenu="MAT 1"}
=======================================================================

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

### Korelacije

```{r warning=FALSE, fig.width=10, fig.height=7}
corrplot(round(cor(korelacije_MAT1, use = "pairwise.complete.obs"), 2), type = "lower",
         diag=FALSE, addCoef.col = 'black', tl.srt = 45)
```

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

### p-vrijednosti korelacija

```{r warning=FALSE, fig.width=10, fig.height=7}
corrplot(round(cor(korelacije_MAT1, use = "pairwise.complete.obs"), 2), type = "lower",
         diag=FALSE, tl.srt = 45, p.mat = testRes_MAT1$p, insig = 'p-value', sig.level = -1)
```

Sankey {data-navmenu="MAT 1"}
=======================================================================

```{r warning=FALSE}
ggplot(st2_long_MAT1, aes(x = x, next_x = next_x, node = node, next_node = next_node,
                     fill = factor(node),
                     label = paste0(node, ' (', pct, '%)'))) +
  geom_sankey(flow.alpha = 0.5, node.color = "black", show.legend = FALSE) +
  geom_sankey_label(size = 3, color = "black", fill= "white", hjust = -0.3) +
  theme_bw() + theme_sankey(base_size = 16) +
  theme(axis.title = element_blank(), axis.text.y = element_blank(), 
        axis.ticks = element_blank(), panel.grid = element_blank())
```

Gustoće {data-navmenu="MZE 1"}
=======================================================================

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

### Funkcije gustoća po aktivnostima

```{r warning=FALSE, fig.width=17, fig.height=9}
ggplot(MZE1_KOL, aes(x=bodovi)) + 
  geom_histogram(aes(y=..density..), binwidth = 1, boundary=1, 
                 color="#ec8ae5", fill="#48d09b", alpha=0.7) +
  geom_density(alpha=.2, fill="yellow") + geom_blank(data=MZE1_blank, aes(x=x,y=y)) +
  scale_x_continuous(name = "bodovi") + 
  scale_y_continuous(limits = c(0, 0.25)) + guides(color = "none", fill = "none") +
  facet_wrap(vars(aktivnost), scales = "free_x") +
  geom_vline(data=AS_MED_MZE1, aes(xintercept=mean_value), color="blue", 
             linetype="dashed", size=0.5, alpha=0.6) +
  geom_vline(data=AS_MED_MZE1, aes(xintercept=median_value), color="red", 
             linetype="dashed", size=0.5, alpha=0.6) +
  geom_text(data = MZE1_text, mapping = aes(label = "\u2022", x = bullet_pos), 
            y = 0.24, color = "blue", size = 9) + 
  geom_text(data = MZE1_text, mapping = aes(label = label_mean, x = x_pos), 
            y = 0.24, hjust = 0) +
  geom_text(data = MZE1_text, mapping = aes(label = "\u2022", x = bullet_pos), 
            y = 0.22, color = "red", size = 9) +
  geom_text(data = MZE1_text, mapping = aes(label = label_median, x = x_pos), 
            y = 0.22, hjust = 0) +
  geom_rug(alpha=0.3)
```

Column {data-width=150}
-----------------------------------------------------------------------

### Brojčane vrijednosti

```{r warning=FALSE}
MZE1_KOL %>% group_by(aktivnost) %>%
  summarize(BROJ = sum(!is.na(bodovi)),
            MEAN = round(mean(bodovi, na.rm = TRUE), 2),
            MEDIAN = median(bodovi, na.rm = TRUE), 
            MIN = min(bodovi, na.rm = TRUE),
            MAX = max(bodovi, na.rm = TRUE)) %>% knitr::kable()
```

Violine {data-navmenu="MZE 1"}
=======================================================================

```{r warning=FALSE, fig.width=17, fig.height=9}
ggplot(MZE1_KOL, aes(x=aktivnost, y=bodovi, fill=aktivnost)) +
  geom_dotplot(binaxis='y', stackdir='center', fill='black', alpha=0.3, dostsize = 0.2) +
  geom_violin(trim=F, alpha=0.3) + geom_boxplot(width=0.05, alpha=0.8) + xlab('') +
  theme(axis.text.x=element_text(size=11), axis.text.y=element_text(size=11), legend.position='none') +
  facet_wrap(vars(aktivnost), scale = "free") +
  theme(axis.text.x=element_blank(), axis.ticks.x=element_blank())
```

Ukupni bodovi {data-navmenu="MZE 1"}
=======================================================================

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

### Frekvencije ukupnih bodova

```{r warning=FALSE, fig.width=10, fig.height=5}
ggplot(podaci_MZE1, aes(x=UKUPNO)) + 
  geom_histogram(binwidth = 1, boundary=1, color="#ec8ae5", fill="#48d09b", alpha=0.7) +
  scale_x_continuous(name = "ukupni bodovi", breaks = seq(0,100,5), limits = c(0,100)) + 
  scale_y_continuous(name = "broj studenata", breaks = seq(0,10)) +
  theme(panel.grid.minor = element_blank())
```

### Ocjene

```{r warning=FALSE, fig.width=10, fig.height=5}
ggplot(podaci_MZE1, aes(x=factor(OCJENA))) +
  geom_bar(width=0.7, fill="steelblue") +
  geom_text(stat="count", aes(label=..count..), vjust=-0.5, nudge_x = -0.2, size = 5) +
  geom_text(aes( label = sprintf('(%s)', scales::percent(..prop..)), group = 1), stat= "count", 
            vjust = -.5, nudge_x = 0.15, size = 5) +
  scale_x_discrete(name = "Ocjena") +
  scale_y_continuous(name = "broj studenata", breaks = seq(0,70,10), limits = c(0,70)) +
  theme(panel.grid.major.x = element_blank())
```

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

### Distribucija bodova

```{r warning=FALSE, fig.width=10, fig.height=7}
ggplot(podaci_MZE1, aes(x=UKUPNO)) + 
  geom_histogram(aes(y=..density..), color="#ec8ae5", fill="#48d09b", alpha=0.5, 
                 breaks = c(0,20,50,61,75,91,100)) +
  geom_vline(aes(xintercept=mean(UKUPNO)),color="blue", linetype="dashed", size=0.5, alpha=0.6) +
  geom_vline(aes(xintercept=median(UKUPNO)),color="red", linetype="dashed", size=0.5, alpha=0.6) +
  annotate(geom="point", x=90, y=0.035, size=2, shape=21, fill="red",color="red") +
  annotate(geom="text", x=91, y=0.035, label="median",size=3.5,hjust=0) +
  annotate(geom="point", x=90, y=0.033, size=2, shape=21, fill="blue",color="blue") +
  annotate(geom="text", x=91, y=0.033, label="mean",size=3.5,hjust=0) +
  geom_density(alpha=.2, fill="yellow") +
  geom_rug(alpha=0.3) +
  scale_x_continuous(name = "ukupni bodovi", breaks = seq(0,100,5), limits = c(0,100)) +
  theme(panel.grid.minor.x = element_blank())
```

Korelacije {data-navmenu="MZE 1"}
=======================================================================

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

### Korelacije

```{r warning=FALSE, fig.width=10, fig.height=7}
corrplot(round(cor(korelacije_MZE1, use = "pairwise.complete.obs"), 2), type = "lower",
         diag=FALSE, addCoef.col = 'black', tl.srt = 45)
```

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

### p-vrijednosti korelacija

```{r warning=FALSE, fig.width=10, fig.height=7}
corrplot(round(cor(korelacije_MZE1, use = "pairwise.complete.obs"), 2), type = "lower",
         diag=FALSE, tl.srt = 45, p.mat = testRes_MZE1$p, insig = 'p-value', sig.level = -1)
```

Sankey {data-navmenu="MZE 1"}
=======================================================================

```{r warning=FALSE}
ggplot(st2_long_MZE1, aes(x = x, next_x = next_x, node = node, next_node = next_node,
                     fill = factor(node),
                     label = paste0(node, ' (', pct, '%)'))) +
  geom_sankey(flow.alpha = 0.5, node.color = "black", show.legend = FALSE) +
  geom_sankey_label(size = 3, color = "black", fill= "white", hjust = -0.35) +
  theme_bw() + theme_sankey(base_size = 16) +
  theme(axis.title = element_blank(), axis.text.y = element_blank(), 
        axis.ticks = element_blank(), panel.grid = element_blank())
```

Studenti
=======================================================================

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

### Matematičke metode za informatičare

- <a href="../trelliscope_MMZI/index.html" target="_blank">studenti MMZI</a> - pojedinačne analize po svakom studentu
- <a href="../grafovi/MMZI_kol1.html" target="_blank">KOL1 klase</a> - graf s kolokvijskim klasama s obzirom na KOL1
- <a href="../grafovi/MMZI_kol2.html" target="_blank">KOL2 klase</a> - graf s kolokvijskim klasama s obzirom na KOL2
- <a href="../grafovi/MMZI_kol3.html" target="_blank">KOL3 klase</a> - graf s kolokvijskim klasama s obzirom na KOL3
- <a href="../grafovi/MMZI_projekt.html" target="_blank">PROJEKT klase</a> - graf s klasama s obzirom na PROJEKT

**Napomena.** Vrhovi u grafu su studenti, a dva vrha su povezana ako je kod pripadnih studenata apsolutna vrijednost
njihovih bodova na pojedinoj aktivnosti manja ili jednaka od 1.

**Napomena.** Za vrijeme i nakon prestanka animacije slika se može zumirati i translatirati. Kada se dođe mišem preko nekog vrha,
pokazuju se detalji o tom vrhu. Ako se klikne na neki vrh, tada se označe svi njegovi susjedi, a ostali vrhovi su sivi.
S obzirom da graf ima jako puno vrhova, animacija može dulje (beskonačno) trajati, a interakcija mišem može biti malo usporena.

### Diskretne strukture s teorijom grafova

- <a href="../trelliscope_DSTG/index.html" target="_blank">studenti DSTG</a> - pojedinačne analize po svakom studentu
- <a href="../grafovi/DSTG_kol1.html" target="_blank">KOL1 klase</a> - graf s kolokvijskim klasama s obzirom na KOL1
- <a href="../grafovi/DSTG_kol2.html" target="_blank">KOL2 klase</a> - graf s kolokvijskim klasama s obzirom na KOL2
- <a href="../grafovi/DSTG_projekt.html" target="_blank">PROJEKT klase</a> - graf s klasama s obzirom na PROJEKT

**Napomena.** Vrhovi u grafu su studenti, a dva vrha su povezana ako je kod pripadnih studenata apsolutna vrijednost
njihovih bodova na pojedinoj aktivnosti manja ili jednaka od 1.

**Napomena.** Za vrijeme i nakon prestanka animacije slika se može zumirati i translatirati. Kada se dođe mišem preko nekog vrha,
pokazuju se detalji o tom vrhu. Ako se klikne na neki vrh, tada se označe svi njegovi susjedi, a ostali vrhovi su sivi.

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

### Matematika 1

- <a href="../trelliscope_MAT1/index.html" target="_blank">studenti MAT1</a> - pojedinačne analize po svakom studentu
- <a href="../grafovi/MAT1_kol1.html" target="_blank">KOL1 klase</a> - graf s kolokvijskim klasama s obzirom na KOL1
- <a href="../grafovi/MAT1_kol2.html" target="_blank">KOL2 klase</a> - graf s kolokvijskim klasama s obzirom na KOL2
- <a href="../grafovi/MAT1_kol3.html" target="_blank">KOL3 klase</a> - graf s kolokvijskim klasama s obzirom na KOL3
- <a href="../grafovi/MAT1_esej.html" target="_blank">ESEJ klase</a> - graf s klasama s obzirom na ESEJ

**Napomena.** Vrhovi u grafu su studenti, a dva vrha su povezana ako je kod pripadnih studenata apsolutna vrijednost
njihovih bodova na pojedinoj aktivnosti manja ili jednaka od 1 (ako je aktivnost različita od ESEJ). Za aktivnost ESEJ
dva vrha su povezana ako je apsolutna vrijednost razlike bodova na eseju manja ili jednaka od 0.5.

**Napomena.** Za vrijeme i nakon prestanka animacije slika se može zumirati i translatirati. Kada se dođe mišem preko nekog vrha,
pokazuju se detalji o tom vrhu. Ako se klikne na neki vrh, tada se označe svi njegovi susjedi, a ostali vrhovi su sivi.
S obzirom da graf ima jako puno vrhova, animacija može dulje (beskonačno) trajati, a interakcija mišem može biti malo usporena.

### Matematika za ekonomiste 1

- <a href="../trelliscope_MZE1/index.html" target="_blank">studenti MZE1</a> - pojedinačne analize po svakom studentu
- <a href="../grafovi/MZE1_kol1.html" target="_blank">KOL1 klase</a> - graf s kolokvijskim klasama s obzirom na KOL1
- <a href="../grafovi/MZE1_kol2.html" target="_blank">KOL2 klase</a> - graf s kolokvijskim klasama s obzirom na KOL2
- <a href="../grafovi/MZE1_kol3.html" target="_blank">KOL3 klase</a> - graf s kolokvijskim klasama s obzirom na KOL3
- <a href="../grafovi/MZE1_zadace.html" target="_blank">DZ klase</a> - graf s klasama s obzirom na DZ

**Napomena.** Vrhovi u grafu su studenti, a dva vrha su povezana ako je kod pripadnih studenata apsolutna vrijednost
njihovih bodova na pojedinoj aktivnosti manja ili jednaka od 1.

**Napomena.** Za vrijeme i nakon prestanka animacije slika se može zumirati i translatirati. Kada se dođe mišem preko nekog vrha,
pokazuju se detalji o tom vrhu. Ako se klikne na neki vrh, tada se označe svi njegovi susjedi, a ostali vrhovi su sivi.
