Divisions

Divisions

Data from KTH Directory API. Click a node for details (opens KTH website), scroll to zoom, drag to pan. Nodes can be dragged around.

Divisions overview

Table of divisions

---
title: "KTH Divisions in ABM"
output: 
  flexdashboard::flex_dashboard:
    logo: beta.png
    orientation: rows
    vertical_layout: fill
    source: embed
---

```{r, results='asis'}
cat(sprintf("", unname(bibliomatrix::palette_kth()["cerise"])
))                  

```

Divisions {.tabset .tabset-fade}
-------------------------------------

### Divisions

Data from KTH Directory API. Click a node for details (opens KTH website), scroll to zoom, drag to pan. Nodes can be dragged around.

```{r}

library(bibliomatrix)
library(dplyr)
library(DT)

fn <- abm_graph_divisions(base_url = "https://www.kth.se/directory/") 

fn

#htmlwidgets::saveWidget(fn, "~/abm-divisions.html")
#browseURL("~/abm-divisions.html")

```

### Divisions overview

```{r}
library(formattable)

ds <- 
  con_bib("sqlite") %>% tbl("division_stats") %>% 
  collect() %>% 
  arrange(nd_researchers, n_pubs) %>% 
  select(starts_with("n"), everything()) %>%
  select(-c("pid", "desc_parent")) %>%
  select(id, desc, everything()) %>%
  filter(n_pubs > 0) %>%
  mutate(q1 = round(100 * nd_researchers / n_staff, 1)) %>%
  mutate(q2 = round(100 * n_pubs_wos / n_pubs, 1)) %>%
  arrange(desc(q2)) %>%
  select(id, desc, n_staff, nd_researchers, q1, n_pubs, n_pubs_wos, q2)

color_tile_divergent <- function(x) ifelse(x <= 0, 
  color_tile("lightpink", "transparent")(x * c(x <= 0)),
  color_tile("transparent", "lightblue")(x * c(x > 0)))

fdt <- function(data)
  as.datatable(rownames = FALSE, class = "stripe", options = list(
    initComplete = htmlwidgets::JS("
                        function(settings, json) {
                          $(this.api().table().container()).css({
                          'font-size': '10px',
                          });
                        }
                    "),
    columnDefs = list(list(className = 'dt-left', targets = "_all")),
    pageLength = 300L, bPaginate = FALSE, scrollY = 380,
    dom = 'ftB'), x = formattable(data, list(
    n_staff = color_bar("lightgray"),
    nd_researchers = color_bar("lightgray"),
    n_pubs = color_bar("lightblue"),
    n_pubs_wos = color_bar("lightblue"),
    q1 = color_tile("transparent", unname(palette_kth()["cerise"])),
    q2 = color_tile("transparent", unname(palette_kth()["cerise"]))
    ))) %>% 
  DT::formatStyle(columns = colnames(.$x$data), `font-size` = "10px")

fdt(ds)
```

### Table of divisions

```{r}

datatable(data = abm_divisions())
```