Organizational belonging for a given KTH user account or kthid

Given an account name or “kthid”, how can we look up the organizational belonging?

library(kthapi)
library(dplyr)

user <- "hoyce"
unit_codes <- kth_profile_school_dep(user)

# organizational belonging for user "hoyce"
unit_codes
#> [1] "t"    "tj"   "tjd"  "tjda"

# use the first two levels of the hierarchy
slug <- paste0(collapse = "/", unit_codes[1:2])

# look up the english lang description for this "slug"
unit2 <- 
  kth_school_dep() %>% 
  inner_join(tibble(slug = slug)) %>%
  select(slug, desc = `description.en`) %>%
  pull(desc)

unit2
#> [1] "IT"

Via the so called “Legacy Profile API v 1.1” we have now looked up that hoyce belongs to the organizational unit IT, at the second level (institutional level) of the organizational hierarchy.

A function that wraps the above calls and returns a data frame is provided for convenience:

kth_belonging_institutional("hoyce")
#> Joining, by = "slug"
#> # A tibble: 1 x 3
#>   kthid slug  desc 
#>   <chr> <chr> <chr>
#> 1 hoyce t/tj  IT

The kth_profile_legacy() function returns a field called worksFor.name-en which represents the lowest level (often level 4) organizational unit name, sometimes provided in Swedish instead of in English, so cannot directly be used to determine institutional belonging.

Level 1 and 2 organizational units

The KTH schools and departments (in this case for the first two levels of the org hierarchy) can be retrieved with kth_school_dep().

In the listing we exclude the kthid identifier, but it exists also for organizational units.

kth_school_dep() %>% 
#  filter(is.na(`_id`)) %>%
  mutate(row = 1:nrow(.)) %>%
  select(row, slug, desc = `description.en`, website) %>%
  knitr::kable()
row slug desc website
1 a SCHOOL OF ARCHITECTURE AND THE BUILT ENVIRONMENT https://www.kth.se/abe
2 c SCHOOL OF ENGINEERING SCIENCES IN CHEMISTRY, BIOTECHNOLOGY AND HEALTH https://www.kth.se/cbh
3 j SCHOOL OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE https://www.kth.se/eecs
4 m SCHOOL OF INDUSTRIAL ENGINEERING AND MANAGEMENT https://www.kth.se/itm
5 s SCHOOL OF ENGINEERING SCIENCES https://www.kth.se/sci
6 t UNIVERSITY ADMINISTRATION https://www.kth.se/om/organisation/universitetsforvaltningen-1.3852
7 a/aaa SCHOOLS OFFICE
8 a/aab SCHOOLS OFFICE OF STUDENT AFFAIRS ABE
9 a/abe ABE SKOLAN
10 a/acp VIABLE CITIES
11 a/ad ARCHITECTURE
12 a/af CIVIL AND ARCHITECTURAL ENGINEERING
13 a/ag URBAN PLANNING AND ENVIRONMENT
14 a/ai REAL ESTATE AND CONSTRUCTION MANAGEMENT
15 a/ak PHILOSOPHY AND HISTORY OF TECHNOLOGY
16 a/al SUSTAINABLE DEVELOPMENT, ENVIRONMENTAL SCIENCE AND ENGINEERING
17 c/cac CBH ADMINISTRATION
18 c/cb GREENHOUSE LABS
19 c/cd DEPARTMENT OF BIOMEDICAL ENGINEERING AND HEALTH SYSTEMS
20 c/ce DEPARTMENT OF CHEMISTRY
21 c/cf DEPARTMENT OF CHEMICAL ENGINEERING
22 c/cg DEPARTMENT OF FIBRE AND POLYMER TECHNOLOGY
23 c/ch DEPARTMENT OF GENE TECHNOLOGY
24 c/cj DEPARTMENT OF PROTEIN SCIENCE
25 c/ck DEPARTMENT OF INDUSTRIAL BIOTECHNOLOGY
26 c/cl DEPARTMENT OF THEORETICAL CHEMISTRY AND BIOLOGY
27 c/cm DEPARTMENT OF ENGINEERING PEDAGOGICS
28 j/jb EECS PROFESSIONAL SUPPORT
29 j/jc CENTRES
30 j/jh DEPARTMENT OF COMPUTER SCIENCE
31 j/jj DEPARTMENT OF ELECTRICAL ENERGY ENGINEERING
32 j/jm DEPARTMENT OF HUMAN CENTERED TECHNOLOGY
33 j/jr DEPARTMENT OF INTELLIGENT SYSTEMS
34 m/maa ITM SCHOOL’S OFFICE
35 m/mab ITM SCHOOLS OFFICE OF STUDENT AFFAIRS
36 m/mad ITM SERVICE CENTER
37 m/me DEPARTMENT OF INDUSTRIAL ECONOMICS AND MANAGEMENT
38 m/mf DEPARTMENT OF MACHINE DESIGN
39 m/mg DEPARTMENT OF PRODUCTION ENGINEERING
40 m/mje DEPARTMENT OF ENERGY TECHNOLOGY
41 m/ml DEPARTMENT OF SUSTAINABLE PRODUCTION DEVELOPMENT
42 m/mm POWERTRAIN MANUFACTURING FOR HEAVY VEHICLES APPLICATION LAB (PMH)
43 m/mv DEPARTMENT OF MATERIALS SCIENCE AND ENGINEERING
44 m/mo LEARNING IN ENGINEERING SCIENCES
45 m/mjc MJC CENTRA
46 s/sa SCI-SKOLAN CENTRALT
47 s/sd AERONAUTICAL & VEHICLE ENGINEERING
48 s/sf MATHEMATICS
49 s/sg MECHANICS
50 s/sh PHYSICS
51 s/sid MATEMATISK FYSIK
52 s/sig TEORETISK FYSIK
53 s/sk APPLIED PHYSICS
54 s/sl SCI ADMINISTRATION
55 s/sm TEKNISK MEKANIK
56 t/ta UNIVERSITETSLEDNING
57 t/td FINANCE
58 t/te HUMAN RESOURCES
59 t/tf UNIVERSITY MANAGEMENT OFFICE
60 t/tg EDUCATION OFFICE
61 t/th RESEARCH SUPPORT OFFICE
62 t/ti COMMUNICATIONS AND BUSINESS LIAISONS
63 t/tj IT
64 t/tk SUSTAINABILITY, REAL ESTATE AND FACILITY SERVICE
65 t/tp INTERNAL AUDIT
66 t/tq KTH INNOVATION
67 t/tr KTH LIBRARY
68 t/ts OPEN LAB
69 t/tt SCILIFELAB ADMINISTRATION