---
title: "Wicked Problems"
format: html
server: shiny
---

```{r}
library(readr)
library(visNetwork)
library(dplyr)
library(tidyr)
```

```{r}
wicked <- read_csv("wicked-problems.csv")
```

Source de l'exemple: <https://lrouviere.github.io/TUTO_GRAPHES/manip-graphes.html#graphes-dynamiques-avec-visnetwork>

```{r}
nodes <- wicked %>%
  transmute(id=Identifiant, label=Texte, group=Couleur)
```

```{r}
edges <- wicked %>% select(Identifiant,Vers) %>% 
  rename(from=Identifiant) %>%
  mutate(to = strsplit(Vers,";"),
         arrows="to") %>%
  unnest(to) %>% select(-Vers) %>% distinct()
```

```{r}
vsn <- visNetwork(nodes,edges, 
           main="Wicked Problems",
           footer="Christian Sarkar & Philip Kotler shorturl.at/fjoqC",
           width = 800,
           height = 800)
```

```{r}
vsn
```

```{r}
visSave(vsn, file = "wicked_problems_standalone.html")
```
