Skip to content

Commit

Permalink
necesita correccion de errores
Browse files Browse the repository at this point in the history
  • Loading branch information
jvillcavillegas committed Dec 12, 2024
1 parent a9cdec3 commit bcaa234
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 63 deletions.
2 changes: 1 addition & 1 deletion tablero-correo.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ library(plotly)
#| message: false
gs4_auth(path = Sys.getenv('GOOGLE_APPLICATION_CREDENTIALS'))
##gs4_auth(path = Sys.getenv('GOOGLE_APPLICATION_CREDENTIALS'))
mailchimp <- read_sheet("1grpIQWXQfVT82vS-mU2JjkKzZ0zwrGes3CFEnWdjYf8")[c(1,4:7, 13:19)]
Expand Down
130 changes: 68 additions & 62 deletions tablero-zenodo.qmd
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
---
title: |
Dashboard de Publicaciones en Zenodo <a href="https://metadocencia.github.io/reporte-mailchimp/" class="btn btn-primary btn-sm" style="margin-left: 10px;"><i class="bi bi-link-45deg"></i> Volver al principio</a>
title: Dashboard de Publicaciones en Zenodo
format:
dashboard:
orientation: rows
nav-buttons:
- icon: images/md-logo.png
href: "https://metadocencia.github.io/reporte-mailchimp/"
theme:
- flatly
- custom.scss
nav: sticky
embed-resources: true
logo: images/md-logo.png
logo-href: "https://metadocencia.github.io/reporte-mailchimp/"
include-in-header:
- text: |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css">
Expand All @@ -31,78 +34,80 @@ library(bsicons)
```

```{r}
gs4_auth(path = Sys.getenv('GOOGLE_APPLICATION_CREDENTIALS'))
##gs4_auth(path = Sys.getenv('GOOGLE_APPLICATION_CREDENTIALS'))
# Cargar datos
zenododata <- read_sheet("https://docs.google.com/spreadsheets/d/1vJ5BffSEJia0HS36zUJU90ivmekopyBVEsKTndtJOQI/edit?gid=1537900891#gid=1537900891")
```


```{r}
#| label: metricas-totales
# Calcular métricas
total_vistas <- sum(zenododata$vistas, na.rm = TRUE)
total_descargas <- sum(zenododata$descargas, na.rm = TRUE)
promedio_vistas <- mean(zenododata$vistas_dias, na.rm = TRUE)
promedio_descargas <- mean(zenododata$descargas_dias, na.rm = TRUE)
promedio_vistas <- mean(zenododata$vistas_mes, na.rm = TRUE)
promedio_descargas <- mean(zenododata$descargas_mes, na.rm = TRUE)
```

## Métricas Generales {height=""}

```{r}
# Crear value boxes
value_box(
title = "Total de Vistas",
title = "Total de vistas",
value = scales::number(total_vistas, big.mark = ","),
showcase = bsicons::bs_icon("eye"),
theme = "primary",
full_width = TRUE,
)
```


```{r}
value_box(
title = "Total de Descargas",
title = "Total de descargas",
value = scales::number(total_descargas, big.mark = ","),
showcase = bsicons::bs_icon("download"),
theme = "info",
full_width = TRUE,
)
```


```{r}
value_box(
title = "Promedio Diario de Vistas",
title = "Promedio mensual de vistas",
value = scales::number(promedio_vistas, accuracy = 0.01),
showcase = bsicons::bs_icon("graph-up"),
theme = "success",
full_width = TRUE
)
```


```{r}
value_box(
title = "Promedio Diario de Descargas",
title = "Promedio mensual de descargas",
value = scales::number(promedio_descargas, accuracy = 0.01),
showcase = bsicons::bs_icon("graph-up-arrow"),
theme = "warning",
full_width = TRUE
)
```


## {height=""}

### Vistas y descargas {width="50%"}
```{r}
#| title: Vistas y descargas por tipo de publicación
#| label: grafico-tipo
#| fig-width: 12
#| fig-height: 6
# Gráfico 1: Vistas y Descargas por Tipo
p1 <- zenododata %>%
mutate(tipo = fct_recode(tipo,
"otros" = "other",
"otras publicaciones" = "publication-other",
"articulos" = "publication-article",
"propuestas" = "publication-proposal",
"reportes" = "publication-report")) %>%
pivot_longer(cols = c(vistas, descargas),
names_to = "metrica",
values_to = "valor") %>%
Expand All @@ -118,21 +123,19 @@ p1 <- zenododata %>%
legend.position = "top"
) +
labs(
title = "Vistas y Descargas por Tipo de Publicación",
x = "Tipo de Publicación",
y = "Cantidad",
fill = "Métrica"
)
ggplotly(p1) %>%
config(displayModeBar = FALSE, showLink = FALSE, displaylogo = FALSE)
```


### Historico {width="50%"}

```{r}
#| title: Progresión histórica de vistas y descargas
#| label: grafico-historico
#| fig-width: 12
#| fig-height: 6
Expand All @@ -155,91 +158,94 @@ p2 <- zenododata %>%
axis.text.x = element_text(angle = 45, hjust = 1)
) +
labs(
title = "Progresión Histórica de Vistas y Descargas",
x = "Fecha de Publicación",
y = "Cantidad",
color = "Métrica"
)
ggplotly(p2) %>%
config(displayModeBar = FALSE, showLink = FALSE, displaylogo = FALSE)
```


## Fila 3 - Gráficas Adicionales {height=""}

### Promedios {width=""}
```{r}
#| title: Promedio de Vistas y Descargas por Publicación
#| label: grafico-promedios
#| fig-width: 12
#| fig-height: 6
# Gráfico 3: Promedio de Vistas y Descargas por Publicación
p3 <- zenododata %>%
select(titulo, vistas_dias, descargas_dias) %>%
pivot_longer(cols = c(vistas_dias, descargas_dias),
names_to = "metrica",
values_to = "valor") %>%
arrange(desc(valor)) %>%
head(15) %>% # Top 15 para mejor visualización
mutate(titulo = substr(titulo, 1, 50)) %>% # Acortar títulos largos
ggplot(aes(x = reorder(titulo, valor), y = valor, fill = metrica)) +
select(titulo, vistas_mes, descargas_mes) %>%
mutate(
titulo = fct_reorder(titulo, vistas_mes, .desc = TRUE) # Ordenar por vistas_mes
) %>%
top_n(10, vistas_mes) %>% # Seleccionar las 10 publicaciones con más vistas
pivot_longer(
cols = c(vistas_mes, descargas_mes),
names_to = "metrica",
values_to = "valor"
)
# Extraer el orden de los títulos después del reordenamiento
ordered_titles <- levels(p3$titulo)
# Crear el gráfico respetando el orden
p3_plot <- ggplot(p3, aes(x = titulo, y = valor, fill = metrica)) +
geom_col(position = "dodge") +
coord_flip() +
scale_fill_manual(values = c("vistas_dias" = "#004F70",
"descargas_dias" = "#C83737"),
labels = c("Vistas por día", "Descargas por día")) +
scale_x_discrete(limits = ordered_titles) + # Usar el orden específico
scale_fill_manual(
values = c("vistas_mes" = "#004F70", "descargas_mes" = "#C83737"),
labels = c("Vistas por mes", "Descargas por mes")
) +
theme_minimal() +
theme(
plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
legend.position = "top",
axis.text.y = element_text(size = 8)
) +
labs(
title = "Promedio de Vistas y Descargas por Publicación",
x = "Título de la Publicación",
y = "Promedio Diario",
y = "Promedio Mensual",
fill = "Métrica"
)
ggplotly(p3) %>%
config(displayModeBar = FALSE, showLink = FALSE, displaylogo = FALSE)
ggplotly(p3_plot) %>%
config(displayModeBar = FALSE, showLink = FALSE, displaylogo = FALSE)
```


## Fila 4 - Gráficas Adicionales {height=""}

::: {.panel-tabset}

### Vistas por día
### Vistas por mes
```{r}
#| label: tabla-top-vistas-dias
#| label: tabla-top-vistas-mes
zenododata %>%
select(titulo, tipo, vistas, descargas, vistas_dias, descargas_dias) %>%
arrange(desc(vistas_dias)) %>%
select(titulo, tipo, vistas, descargas, vistas_mes, descargas_mes) %>%
arrange(desc(vistas_mes)) %>%
head(10) %>%
gt() %>%
tab_header(
title = "Top 10 Publicaciones por Vistas por Día"
title = "Top 10 Publicaciones por Vistas por mes"
) %>%
fmt_number(
columns = c(vistas, descargas),
decimals = 0,
use_seps = TRUE
) %>%
fmt_number(
columns = c(vistas_dias, descargas_dias),
columns = c(vistas_mes, descargas_mes),
decimals = 2
) %>%
cols_label(
titulo = "Título",
tipo = "Tipo",
vistas = "Vistas",
descargas = "Descargas",
vistas_dias = "Vistas/Día",
descargas_dias = "Descargas/Día"
vistas_mes = "Vistas/mes",
descargas_mes = "Descargas/mes"
) %>%
tab_style(
style = list(
Expand All @@ -254,33 +260,33 @@ zenododata %>%
opt_row_striping()
```

### Descargas por día
### Descargas por mes
```{r}
#| label: tabla-top-descargas-dias
#| label: tabla-top-descargas-mes
zenododata %>%
select(titulo, tipo, vistas, descargas, vistas_dias, descargas_dias) %>%
arrange(desc(descargas_dias)) %>%
select(titulo, tipo, vistas, descargas, vistas_mes, descargas_mes) %>%
arrange(desc(descargas_mes)) %>%
head(10) %>%
gt() %>%
tab_header(
title = "Top 10 Publicaciones por Descargas por Día"
title = "Top 10 Publicaciones por Descargas por mes"
) %>%
fmt_number(
columns = c(vistas, descargas),
decimals = 0,
use_seps = TRUE
) %>%
fmt_number(
columns = c(vistas_dias, descargas_dias),
columns = c(vistas_mes, descargas_mes),
decimals = 2
) %>%
cols_label(
titulo = "Título",
tipo = "Tipo",
vistas = "Vistas",
descargas = "Descargas",
vistas_dias = "Vistas/Día",
descargas_dias = "Descargas/Día"
vistas_mes = "Vistas/mes",
descargas_mes = "Descargas/mes"
) %>%
tab_style(
style = list(
Expand All @@ -299,7 +305,7 @@ zenododata %>%
```{r}
#| label: tabla-top-vistas-total
zenododata %>%
select(titulo, tipo, vistas, descargas, vistas_dias, descargas_dias) %>%
select(titulo, tipo, vistas, descargas, vistas_mes, descargas_mes) %>%
arrange(desc(vistas)) %>%
head(10) %>%
gt() %>%
Expand All @@ -312,16 +318,16 @@ zenododata %>%
use_seps = TRUE
) %>%
fmt_number(
columns = c(vistas_dias, descargas_dias),
columns = c(vistas_mes, descargas_mes),
decimals = 2
) %>%
cols_label(
titulo = "Título",
tipo = "Tipo",
vistas = "Vistas",
descargas = "Descargas",
vistas_dias = "Vistas/Día",
descargas_dias = "Descargas/Día"
vistas_mes = "Vistas/mes",
descargas_mes = "Descargas/mes"
) %>%
tab_style(
style = list(
Expand All @@ -340,7 +346,7 @@ zenododata %>%
```{r}
#| label: tabla-top-descargas-total
zenododata %>%
select(titulo, tipo, vistas, descargas, vistas_dias, descargas_dias) %>%
select(titulo, tipo, vistas, descargas, vistas_mes, descargas_mes) %>%
arrange(desc(descargas)) %>%
head(10) %>%
gt() %>%
Expand All @@ -353,16 +359,16 @@ zenododata %>%
use_seps = TRUE
) %>%
fmt_number(
columns = c(vistas_dias, descargas_dias),
columns = c(vistas_mes, descargas_mes),
decimals = 2
) %>%
cols_label(
titulo = "Título",
tipo = "Tipo",
vistas = "Vistas",
descargas = "Descargas",
vistas_dias = "Vistas/Día",
descargas_dias = "Descargas/Día"
vistas_mes = "Vistas/mes",
descargas_mes = "Descargas/mes"
) %>%
tab_style(
style = list(
Expand All @@ -377,4 +383,4 @@ zenododata %>%
opt_row_striping()
```

:::
:::

0 comments on commit bcaa234

Please # to comment.