When I plot the ER diagram of my database with the dm
package with dm_draw()
it draws 10 tables stacked on top of each other in a single column and it puts the table with the primary key into another column:
suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(dm))
Everybody <- tibble(project = 27, who = 1)
Demographics <- tibble(project = 27, who = 1, Age = 1, Sex = "x", Education = "some")
Psychiatric <- tibble(project = 27, who = 1)
Randomization <- tibble(project = 27, who = 1, when = 1)
Site <- tibble(project = 27, who = 1, site = 1)
ASI <- tibble(project = 27, who = 1, score = 1)
RBS <- tibble(project = 27, who = 1, score = 1)
TLFB <- tibble(project = 27, who = 1, when = 1, what = "drug")
UDS <- tibble(project = 27, who = 1, when = 1, what = "drug")
Treatment <- tibble(project = 27, who = 1, what = "drug", amount = 1)
Withdrawl <- tibble(project = 27, who = 1, severity = 1)
nokeys <- dm(ASI, Demographics, Everybody, Psychiatric, Randomization, RBS,
Site, TLFB, Treatment, UDS, Withdrawl)
primary <- nokeys %>%
dm_add_pk(table = Everybody, columns = who)
allKeys <- primary %>%
dm_add_fk(table = Demographics, column = who, ref_table = Everybody) %>%
dm_add_fk(table = Psychiatric, column = who, ref_table = Everybody) %>%
dm_add_fk(table = Randomization, column = who, ref_table = Everybody) %>%
dm_add_fk(table = Site, column = who, ref_table = Everybody) %>%
dm_add_fk(table = ASI, column = who, ref_table = Everybody) %>%
dm_add_fk(table = RBS, column = who, ref_table = Everybody) %>%
dm_add_fk(table = TLFB, column = who, ref_table = Everybody) %>%
dm_add_fk(table = UDS, column = who, ref_table = Everybody) %>%
dm_add_fk(table = Treatment, column = who, ref_table = Everybody) %>%
dm_add_fk(table = Withdrawl, column = who, ref_table = Everybody)
allKeys %>%
dm_draw(view_type = "all")
Is there some way to specify that I want two columns each showing five tables. The documentation for dm_draw()
notes that it is returning a grViz
object. I tried saving the output of dm_draw
as an object but I can't figure out how to get DiagrammeR
to plot the object. I am guessing that in theory I can use DiagrammeR to specify the position details but I am clueless....
question from:
https://stackoverflow.com/questions/66049457/can-i-position-the-tables-plotted-with-the-r-dm-package