I wish to create a Space Adjacency Matrix in R
, preferably using ggplot/tidyverse for consistency with other scripts, but I am open to other solutions.
Here is what I am looking for.
A Space Adjacency Matrix is used in interior and architectural design to illustrate relationships (adjacencies) between spaces within a building.
Each space in the building has a relationship (or lack of relationship) to every other space.
The input data is likely formatted similarly to this:
rel.ABCD <- data.frame(
id = c(1,2,3,4,5,6),
x1 = c("A","A","A","B","B","C"),
x2 = c("B","C","D","C","D","D"),
relation = c(1,2,1,3,2,1)
)
rel.ABCD
#> id x1 x2 relation
#> 1 1 A B 1
#> 2 2 A C 2
#> 3 3 A D 1
#> 4 4 B C 3
#> 5 5 B D 2
#> 6 6 C D 1
Created on 2022-04-11 by the reprex package (v2.0.1)
Four spaces (A, B, C and D) exist in the example above. Each has a type of relation
with the other spaces. Spaces A and B (id
1) have a relation
type of 1, spaces B and C (id
4) have a relation
type of 3, etc.
In some ways, the Space Adjacency Matrix is similar to a correlation table (in format, not function), matching lists of entities intersect and the value for the relationship is shown at the intersection. The difference is that instead of labels existing on both the x-axes and y-axes, they exist on the y-axes only, like in the example below from vectorworks.net.
The relation
is displayed at the intersecting grid for each room pair (e.g. dispatch and office have a relationship type 5, storage and shop have a relationship type 1, etc.). The relation
is typically depicted as an icon, number or fill colour.
How can I generate this graph?