Sección A

0

7

25

2

Notas inferiores a 4,0

Notas superiores a 4,0

Sección B

1

3

15

2

Notas inferiores a 4,0

Notas superiores a 4,0

Notas Sección A

Notas Sección B

---
title: "TDI-20201"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: fill
    source_code: embed
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message= FALSE, warning= FALSE)
library(flexdashboard)
library(dplyr)
library(tidyr)
#library(lubridate)
library(ggplot2)
library(plotly)
library(readr)
#library(formattable)
library(DT)
```

```{r dataset}
library(readxl)
```

# Sección A
```{r}
# controles opcionales de página
# {data-vertical_layout=scroll}
# {data-orientation=rows}
notasf <- read_excel("data/Notas-TDI-A-20211.xlsx", sheet = "Notas") # %>%
  # select(c(-Correo))

names(notasf) <- stringr::str_replace_all(names(notasf), c(" " = "." , "," = "" ))

# NSP
nsp <- notasf %>%
  filter(is.na(Lectura.1)) %>% count()
# notas inferior a 4.0
bajas <- notasf %>%
  filter(Lectura.1 < 4.0) %>% count()
# notas entre 4 y 5,5
medias <- notasf %>%
  filter(Lectura.1 >= 4.0 , Lectura.1 <= 5.5) %>% count()
# nota alta
altas <- notasf %>%
  filter(Lectura.1 >=5.6) %>% count()
```

##
###
```{r}
valueBox(bajas, caption = "Notas bajo 4.0",
         icon = "fa-exclamation-triangle",
         color = "danger"
)
```

###
```{r}
valueBox(medias, caption = "4.0 a 5.5",
         icon = "fa-signal",
         color = "info"
)
```

###
```{r}
valueBox(altas, caption = "Notas superiores",
         icon = "fa-thumbs-up",
         color = "success"
)
```

###
```{r}
valueBox(nsp, caption = "NSP",
         icon = "fa-user",
         color = "info"
)
```

##
###
```{r}
nbajas <- bajas/count(notasf)
nbajas <- round(nbajas * 100, 0)
gauge(nbajas$n, min= 0, max = 100, symbol = "%",
      gaugeSectors(success = c(80, 100), warning = c(40, 79), danger = c(0, 39)))
```

> Notas inferiores a 4,0

###
```{r}
naltas <- (medias+altas)/count(notasf)
naltas <- round(naltas * 100, 0)
gauge(naltas$n, min= 0, max = 100, symbol = "%",
      gaugeSectors(success = c(80, 100), warning = c(40, 79), danger = c(0, 39)))
```

> Notas superiores a 4,0

##

###
```{r echo=FALSE}
# p <- notas %>%
#   ggplot(aes(x=Nota)) +
#   stat_boxplot(geom ='errorbar', width = 0.1) +
#   geom_boxplot(color="black", outlier.colour = "red", outlier.shape = 0.2) +
#   theme_bw() #+
#   #theme(axis.text = element_text(size = 9))
# f <- ggplotly(p)
# f
notas <- notasf %>%
  filter(!is.na(Lectura.1)) # sacar puntajes NA
p <- plot_ly(y = notas$Lectura.1, type = "box", boxpoints = "all",
         pointpos = 0, name = "Lectura 1"
         )
p <- p %>% 
  add_trace(y = notas$Lectura.2, name = "Lectura 2") %>%
  layout(showlegend = FALSE)
p
```

###
```{r echo=FALSE, message=FALSE}
##
### Distribución de notas

##
### Distribución de notas
lecturasa = na.omit(notasf)

p <- ggplot(lecturasa, aes(x=x) ) +
  geom_histogram( aes(x = lecturasa$Lectura.1), fill="#69b3a2", bins=16) +
  geom_label( aes(x=4.5, y=0.25, label="Lectura 1"), color="#69b3a2") +
  geom_histogram( aes(x = lecturasa$Lectura.2), fill= "#404080", bins = 16) +
  geom_label( aes(x=4.5, y=-0.25, label="Lectura 2"), color="#404080") +
  theme_bw() +
  xlab("Notas")

ggplotly(p)
```


```{r}
# notas %>%
#   select(c(-nombre,-Apellido)) %>%
# summary(notas)
```


# Sección B
```{r}
# controles opcionales de página
# {data-vertical_layout=scroll}
# {data-orientation=rows}
notasB <- read_excel("data/Notas-TDI-B-20211.xlsx", sheet = "Notas") #%>%
  #select(c(-Correo))

names(notasB) <- stringr::str_replace_all(names(notasB), c(" " = "." , "," = "" ))

# NSP
nsp <- notasB %>%
  filter(is.na(Lectura.1)) %>% count()
# notas inferior a 4.0
bajas <- notasB %>%
  filter(Lectura.1 < 4.0) %>% count()
# notas entre 4 y 5,5
medias <- notasB %>%
  filter(Lectura.1 >= 4.0 , Lectura.1 <= 5.5) %>% count()
# nota alta
altas <- notasB %>%
  filter(Lectura.1 >=5.6) %>% count()
```

##
###
```{r}
valueBox(bajas, caption = "Notas bajo 4.0",
         icon = "fa-exclamation-triangle",
         color = "danger"
)
```

###
```{r}
valueBox(medias, caption = "4.0 a 5.5",
         icon = "fa-signal",
         color = "info"
)
```

###
```{r}
valueBox(altas, caption = "Notas superiores",
         icon = "fa-thumbs-up",
         color = "success"
)
```

###
```{r}
valueBox(nsp, caption = "NSP",
         icon = "fa-user",
         color = "info"
)
```

##
###
```{r}
nbajas <- bajas/count(notasB)
nbajas <- round(nbajas * 100, 0)
gauge(nbajas$n, min= 0, max = 100, symbol = "%",
      gaugeSectors(success = c(80, 100), warning = c(40, 79), danger = c(0, 39)))
```

> Notas inferiores a 4,0

###
```{r}
naltas <- (medias+altas)/count(notasB)
naltas <- round(naltas * 100, 0)
gauge(naltas$n, min= 0, max = 100, symbol = "%",
      gaugeSectors(success = c(80, 100), warning = c(40, 79), danger = c(0, 39)))
```

> Notas superiores a 4,0

##

###
```{r echo=FALSE}

notas <- notasB %>%
  filter(!is.na(Lectura.1)) # sacar puntajes NA
p <- plot_ly(y = notas$Lectura.1, type = "box", boxpoints = "all",
         pointpos = 0, name = "Lectura 1"
         )
p <- p %>% 
  add_trace(y = notas$Lectura.2, name = "Lectura 2") %>%
  layout(showlegend = FALSE)
p
```

###
```{r}
##
### Distribución de notas
lecturasb = na.omit(notasB)

p <- ggplot(lecturasb, aes(x=x) ) +
  geom_histogram( aes(x = lecturasb$Lectura.1), fill="#69b3a2", bins=16) +
  geom_label( aes(x=4.5, y=0.25, label="Lectura 1"), color="#69b3a2") +
  geom_histogram( aes(x = lecturasb$Lectura.2), fill= "#404080", bins = 16) +
  geom_label( aes(x=4.5, y=-0.25, label="Lectura 2"), color="#404080") +
  theme_bw() +
  xlab("Notas")

ggplotly(p)
```

# Notas Sección A
##
```{r}
notasf %>%
   DT::datatable()
```


# Notas Sección B
##
```{r}
notasB %>%
   DT::datatable()
```