Using pixarfilms with dm

Overview

The {pixarfilms} R package has been added to the {dm} R package, which is a package “for working with multiple related tables, stored as data frames or in a relational database.”

Because all of the tables created in {pixarfilms} are connected by each film, this gives an interesting opportunity to explore these interconnected tables together.

Setup

library(dm)
#> 
#> Attaching package: 'dm'
#> The following object is masked from 'package:stats':
#> 
#>     filter
library(pixarfilms)

Setup

# Create dm object
dm <- dm(
  pixar_films,
  pixar_people,
  academy,
  box_office,
  genres,
  public_response
  # pixar_rankings  # Not yet in package
)

# Create primary keys
dm <-
  dm %>%
  dm_add_pk(pixar_films, film) %>%
  dm_add_pk(academy, c(film, award_type)) %>%
  dm_add_pk(box_office, film) %>%
  dm_add_pk(genres, c(film, category, value)) %>%
  # dm_add_pk(pixar_rankings, c(film, source)) %>%
  dm_add_pk(public_response, film)

# Create foreign keys
dm <-
  dm %>%
  dm_add_fk(pixar_people, film, pixar_films) %>%
  dm_add_fk(academy, film, pixar_films) %>%
  dm_add_fk(box_office, film, pixar_films) %>%
  dm_add_fk(genres, film, pixar_films) %>%
  # dm_add_fk(pixar_rankings, film, pixar_films) %>%
  dm_add_fk(public_response, film, pixar_films)

# Add splash of color
dm <-
  dm %>%
  dm_set_colors(
    `#5B9BD5` = pixar_films,
    `#ED7D31` = c(academy, box_office, genres, public_response),
    `#70AD47` = pixar_people
  )

Explore

dm
#> ── Metadata ────────────────────────────────────────────────────────────────────
#> Tables: `pixar_films`, `pixar_people`, `academy`, `box_office`, `genres`, `public_response`
#> Columns: 37
#> Primary keys: 5
#> Foreign keys: 5
dm %>%
  dm_examine_cardinalities()
#> • FK: pixar_people$(`film`) -> pixar_films$(`film`): surjective mapping (child: 1 to n -> parent: 1)
#> • FK: academy$(`film`) -> pixar_films$(`film`): generic mapping (child: 0 to n -> parent: 1)
#> • FK: box_office$(`film`) -> pixar_films$(`film`): bijective mapping (child: 1 -> parent: 1)
#> • FK: genres$(`film`) -> pixar_films$(`film`): surjective mapping (child: 1 to n -> parent: 1)
#> • FK: public_response$(`film`) -> pixar_films$(`film`): bijective mapping (child: 1 -> parent: 1)
dm %>%
  dm_examine_constraints()
#> ℹ All constraints satisfied.

System information

sessionInfo()
#> R version 4.6.1 (2026-06-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 26.04.1 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#>  [1] dm_1.1.2          dbplyr_2.6.0      gghighlight_0.5.0 irr_0.85         
#>  [5] lpSolve_5.6.23    stringr_1.6.0     forcats_1.0.1     tidyr_1.3.2      
#>  [9] patchwork_1.3.2   lubridate_1.9.5   ggplot2_4.0.3     dplyr_1.2.1      
#> [13] pixarfilms_0.2.1  rmarkdown_2.32   
#> 
#> loaded via a namespace (and not attached):
#>  [1] sass_0.4.10        utf8_1.2.6         generics_0.1.4     RSQLite_3.53.3    
#>  [5] stringi_1.8.9      digest_0.6.39      magrittr_2.0.5     evaluate_1.0.5    
#>  [9] grid_4.6.1         timechange_0.4.0   RColorBrewer_1.1-3 blob_1.3.0        
#> [13] fastmap_1.2.0      jsonlite_2.0.0     ggrepel_0.9.8      backports_1.5.1   
#> [17] DBI_1.3.0          purrr_1.2.2        scales_1.4.0       jquerylib_0.1.4   
#> [21] cli_3.6.6          rlang_1.3.0        bit64_4.8.6        withr_3.0.3       
#> [25] cachem_1.1.0       yaml_2.3.12        otel_0.2.0         ggbeeswarm_0.7.3  
#> [29] tools_4.6.1        memoise_2.0.1      buildtools_1.0.0   vctrs_0.7.3       
#> [33] R6_2.6.1           lifecycle_1.0.5    bit_4.6.0          vipor_0.4.7       
#> [37] pkgconfig_2.0.3    beeswarm_0.4.0     pillar_1.11.1      bslib_0.12.0      
#> [41] gtable_0.3.6       Rcpp_1.1.2         glue_1.8.1         xfun_0.62         
#> [45] tibble_3.3.1       tidyselect_1.2.1   sys_3.4.3          knitr_1.52        
#> [49] farver_2.1.2       igraph_2.3.4       htmltools_0.5.9    maketools_1.3.2   
#> [53] labeling_0.4.3     compiler_4.6.1     S7_0.2.2