Víctor Gauto
  • Tidytuesday
  • Publicaciones
  • Mapas de Argentina
  • Visualizaciones
  1. 2025
  2. Semana 18

Sitio en construcción

  • Inicio
  • 2025
    • Semana 02
    • Semana 03
    • Semana 04
    • Semana 05
    • Semana 06
    • Semana 07
    • Semana 08
    • Semana 09
    • Semana 10
    • Semana 11
    • Semana 12
    • Semana 13
    • Semana 14
    • Semana 15
    • Semana 16
    • Semana 17
    • Semana 18
    • Semana 19
    • Semana 20
    • Semana 21
  • 2024
    • Semana 02
    • Semana 03
    • Semana 04
    • Semana 05
    • Semana 06
    • Semana 07
    • Semana 08
    • Semana 09
    • Semana 10
    • Semana 11
    • Semana 12
    • Semana 13
    • Semana 14
    • Semana 15
    • Semana 16
    • Semana 17
    • Semana 18
    • Semana 19
    • Semana 20
    • Semana 21
    • Semana 22
    • Semana 23
    • Semana 24
    • Semana 25
    • Semana 26
    • Semana 27
    • Semana 28
    • Semana 29
    • Semana 30
    • Semana 31
    • Semana 32
    • Semana 33
    • Semana 34
    • Semana 35
    • Semana 36
    • Semana 37
    • Semana 38
    • Semana 39
    • Semana 40
    • Semana 41
    • Semana 42
    • Semana 43
    • Semana 44
    • Semana 45
    • Semana 46
    • Semana 47
    • Semana 48
    • Semana 49
    • Semana 50
    • Semana 51
    • Semana 52
    • Semana 53
  • 2023
    • Semana 07
    • Semana 12
    • Semana 13
    • Semana 14
    • Semana 15
    • Semana 16
    • Semana 17
    • Semana 18
    • Semana 19
    • Semana 20
    • Semana 21
    • Semana 22
    • Semana 23
    • Semana 24
    • Semana 25
    • Semana 26
    • Semana 27
    • Semana 28
    • Semana 29
    • Semana 30
    • Semana 31
    • Semana 32
    • Semana 33
    • Semana 34
    • Semana 35
    • Semana 36
    • Semana 37
    • Semana 38
    • Semana 39
    • Semana 40
    • Semana 41
    • Semana 42
    • Semana 43
    • Semana 44
    • Semana 45
    • Semana 46
    • Semana 47
    • Semana 48
    • Semana 49
    • Semana 50
    • Semana 51
    • Semana 52

Contenido

  • Paquetes
  • Estilos
  • Epígrafe
  • Datos
  • Procesamiento
  • Figura
  • Editar esta página
  • Informar de un problema
  1. 2025
  2. Semana 18

Semana 18

  • Mostrar todo el código
  • Ocultar todo el código

  • Ver el código fuente
plot_usmap
Autor

Víctor Gauto

Fecha de publicación

28 de mayo de 2025

Cantidad de proyectos de investigación finalizados por estado en EE.UU.

Semana 18, 2025

Paquetes

Ocultar código
library(glue)
library(ggtext)
library(showtext)
library(tidyverse)

Estilos

Colores.

Ocultar código
c1 <- "#420F75"
c2 <- "#552000"
c3 <- "white"
c4 <- "#E1C1C8"

Fuentes: Ubuntu y JetBrains Mono.

Ocultar código
font_add(
  family = "ubuntu",
  regular = "././fuente/Ubuntu-Regular.ttf",
  bold = "././fuente/Ubuntu-Bold.ttf",
  italic = "././fuente/Ubuntu-Italic.ttf"
)

font_add(
  family = "jet",
  regular = "././fuente/JetBrainsMonoNLNerdFontMono-Regular.ttf"
)

showtext_auto()
showtext_opts(dpi = 300)

Epígrafe

Ocultar código
fuente <- glue(
    "Datos: <span style='color:{c1};'><span style='font-family:jet;'>",
    "{{<b>tidytuesdayR</b>}}</span> semana 18, ",
    "<b>U.S. National Science Foundation</b>.</span>"
)

autor <- glue("<span style='color:{c1};'>**Víctor Gauto**</span>")
icon_twitter <- glue("<span style='font-family:jet;'>&#xf099;</span>")
icon_instagram <- glue("<span style='font-family:jet;'>&#xf16d;</span>")
icon_github <- glue("<span style='font-family:jet;'>&#xf09b;</span>")
icon_mastodon <- glue("<span style='font-family:jet;'>&#xf0ad1;</span>")
icon_bsky <- glue("<span style='font-family:jet;'>&#xe28e;</span>")
usuario <- glue("<span style='color:{c1};'>**vhgauto**</span>")
sep <- glue("**|**")

mi_caption <- glue(
    "{fuente}<br>{autor} {sep} {icon_github} {icon_twitter} {icon_instagram} ",
    "{icon_mastodon} {icon_bsky} {usuario}"
)

Datos

Ocultar código
tuesdata <- tidytuesdayR::tt_load(2025, 18)
nsf_terminations <- tuesdata$nsf_terminations

Procesamiento

Me interesa ver la distribución de proyectos cancelados por estado de EE.UU, mediante un mapa.

Ocultar código
d <- nsf_terminations |> 
  count(org_state) |> 
  rename(state = org_state)

Figura

Subtítulo indicando la cantidad de proyectos afectados y el estado con mayor cantidad.

Ocultar código
mi_subtitulo <- glue(
  "La administración Trump decidió terminar con {{{c1} _**{nrow(nsf_terminations)}**_} 
  subvenciones a investigación.
  **California** fue el estado más afectado con {{{c2} _**{d[d$n == max(d$n),]$n}**_} proyectos finalizados."
)
Ocultar código
g <- usmap::plot_usmap(
  exclude = c("AK", "HI"),
  data = d,
  values = "n",
  color = c4,
  linewidth = .6
) +
  coord_sf(expand = FALSE) +
  scale_fill_steps2(
    low = c1,
    mid = c3,
    high = c2,
    midpoint = 64,
    breaks = c(1, seq(25, 125, 25)),
    limits = c(1, 125)
  ) +
  labs(
    subtitle = mi_subtitulo,
    fill = "Cantidad de\nproyectos afectados",
    caption = mi_caption
  ) +
  theme_void(base_family = "ubuntu", base_size = 20) +
  theme(
    plot.margin = margin(t = 10, b = 5, r = 15, l = 15),
    plot.background = element_rect(fill = c4, color = NA),
    plot.subtitle = marquee::element_marquee(
      width = .92, lineheight = 1.3, size = rel(1.), margin = margin(b = 15)
    ),
    plot.caption = element_markdown(
      color = c2, size = rel(.5), margin = margin(b = 10, t = 10),
      lineheight = 1.3
    ),
    legend.position = "inside",
    legend.position.inside = c(0, 0),
    legend.justification.inside = c(0, 0),
    legend.title = element_text(size = rel(.7)),
    legend.text = element_text(family = "jet", size = rel(.5))
  )

Guardo.

Ocultar código
ggsave(
  plot = g,
  filename = "tidytuesday/2025/semana_18.png",
  width = 30,
  height = 22,
  units = "cm"
)
Subir
Semana 17
Semana 19
Ejecutar el código
---
format:
  html:
    code-fold: show
    code-summary: "Ocultar código"
    code-line-numbers: false
    code-annotations: false
    code-link: true
    code-tools:
        source: true
        toggle: true
        caption: "Código"
    code-overflow: scroll
    page-layout: full
editor_options:
  chunk_output_type: console
categories:
  - plot_usmap
execute:
  eval: false
  echo: true
  warning: false
title: "Semana 18"
date: last-modified
author: Víctor Gauto
---

Cantidad de proyectos de investigación finalizados por estado en EE.UU.

![Semana 18, 2025](semana_18.png)

## Paquetes

```{r}
library(glue)
library(ggtext)
library(showtext)
library(tidyverse)
```

## Estilos

Colores.

```{r}
c1 <- "#420F75"
c2 <- "#552000"
c3 <- "white"
c4 <- "#E1C1C8"
```

Fuentes: Ubuntu y JetBrains Mono.

```{r}
font_add(
  family = "ubuntu",
  regular = "././fuente/Ubuntu-Regular.ttf",
  bold = "././fuente/Ubuntu-Bold.ttf",
  italic = "././fuente/Ubuntu-Italic.ttf"
)

font_add(
  family = "jet",
  regular = "././fuente/JetBrainsMonoNLNerdFontMono-Regular.ttf"
)

showtext_auto()
showtext_opts(dpi = 300)
```

## Epígrafe

```{r}
fuente <- glue(
    "Datos: <span style='color:{c1};'><span style='font-family:jet;'>",
    "{{<b>tidytuesdayR</b>}}</span> semana 18, ",
    "<b>U.S. National Science Foundation</b>.</span>"
)

autor <- glue("<span style='color:{c1};'>**Víctor Gauto**</span>")
icon_twitter <- glue("<span style='font-family:jet;'>&#xf099;</span>")
icon_instagram <- glue("<span style='font-family:jet;'>&#xf16d;</span>")
icon_github <- glue("<span style='font-family:jet;'>&#xf09b;</span>")
icon_mastodon <- glue("<span style='font-family:jet;'>&#xf0ad1;</span>")
icon_bsky <- glue("<span style='font-family:jet;'>&#xe28e;</span>")
usuario <- glue("<span style='color:{c1};'>**vhgauto**</span>")
sep <- glue("**|**")

mi_caption <- glue(
    "{fuente}<br>{autor} {sep} {icon_github} {icon_twitter} {icon_instagram} ",
    "{icon_mastodon} {icon_bsky} {usuario}"
)
```

## Datos

```{r}
tuesdata <- tidytuesdayR::tt_load(2025, 18)
nsf_terminations <- tuesdata$nsf_terminations
```

## Procesamiento

Me interesa ver la distribución de proyectos cancelados por estado de EE.UU, mediante un mapa.

```{r}
d <- nsf_terminations |> 
  count(org_state) |> 
  rename(state = org_state)
```

## Figura

Subtítulo indicando la cantidad de proyectos afectados y el estado con mayor cantidad.

```{r}
mi_subtitulo <- glue(
  "La administración Trump decidió terminar con {{{c1} _**{nrow(nsf_terminations)}**_} 
  subvenciones a investigación.
  **California** fue el estado más afectado con {{{c2} _**{d[d$n == max(d$n),]$n}**_} proyectos finalizados."
)
```

```{r}
g <- usmap::plot_usmap(
  exclude = c("AK", "HI"),
  data = d,
  values = "n",
  color = c4,
  linewidth = .6
) +
  coord_sf(expand = FALSE) +
  scale_fill_steps2(
    low = c1,
    mid = c3,
    high = c2,
    midpoint = 64,
    breaks = c(1, seq(25, 125, 25)),
    limits = c(1, 125)
  ) +
  labs(
    subtitle = mi_subtitulo,
    fill = "Cantidad de\nproyectos afectados",
    caption = mi_caption
  ) +
  theme_void(base_family = "ubuntu", base_size = 20) +
  theme(
    plot.margin = margin(t = 10, b = 5, r = 15, l = 15),
    plot.background = element_rect(fill = c4, color = NA),
    plot.subtitle = marquee::element_marquee(
      width = .92, lineheight = 1.3, size = rel(1.), margin = margin(b = 15)
    ),
    plot.caption = element_markdown(
      color = c2, size = rel(.5), margin = margin(b = 10, t = 10),
      lineheight = 1.3
    ),
    legend.position = "inside",
    legend.position.inside = c(0, 0),
    legend.justification.inside = c(0, 0),
    legend.title = element_text(size = rel(.7)),
    legend.text = element_text(family = "jet", size = rel(.5))
  )
```

Guardo.

```{r}
ggsave(
  plot = g,
  filename = "tidytuesday/2025/semana_18.png",
  width = 30,
  height = 22,
  units = "cm"
)
```

Creado con y

Víctor Gauto

  • Editar esta página
  • Informar de un problema