Skip to content

blockr.dm ​

Relational data: bring in a whole data model (many linked tables) as one source, pull tables out of it, filter across the relationships. For data that lives in a database rather than a single frame.

Example data model ​

new_dm_example_block() · input

Load a pre-built dm from example datasets

ArgumentDescription
datasetCharacter. ID of the dm example dataset to load. One of: "bi_star_schema" (retail star schema), "nycflights13", "insurancedata". Availability depends on installed data packages; call dm_example_choices() for the live ...

Add keys ​

new_dm_add_keys_block() · structured

Add primary and foreign key relationships to dm

ArgumentDescription
pk_tableCharacter. Name of the table to receive the primary key.
pk_columnCharacter. Column name on pk_table to mark as the primary key.
fk_tablesCharacter vector of table names that should get a foreign key pointing to pk_table.
fk_columnCharacter. Column name on each fk_tables entry to mark as the foreign key. Must match pk_column in meaning, and usually in name.

Create dm ​

new_dm_block() · structured

Combine data frames into a dm (data model) object

ArgumentDescription
infer_keysLogical. TRUE (default) auto-infers primary and foreign key relationships from matching column names. FALSE leaves the dm key-less (use dm_add_keys_block to set keys explicitly).

Crossfilter ​

new_crossfilter_block() · structured

Client-side crossfilter for data frames and dm objects using crossfilter2.js

ArgumentDescription
active_dimsPer-table active filter columns. Object: table name -> array of column names that are eligible for filtering. For a single data frame input (not a dm), use ".tbl" as the table name.
filtersPer-table categorical filters. Object: table name -> {column -> array of kept values}. Values not listed are excluded.
subgroupA second column the board is split by, under pinned: tables nest it under the group, charts facet by it. Same eligible columns as pinned, minus the pinned one. Null for none.
groupsGroup definitions for the pinned column and the subgroup. Object: column name -> {columns: array of {name, members: array of levels, custom: boolean}, in table order}. A column with an empty name is one level on its o...
range_filtersPer-table numeric/date range filters. Object: table name -> {column -> [min, max]}.
measureAggregation measure as a "table.column" string, or null for row counts. Used in linked summary views.
agg_funcAggregation function applied to measure. One of "sum" or "mean". Only used when measure is set.
featuredColumns worth showing up front: they appear as one-click chips above the filter cards and supply the choices for pinned. Array of column names, resolved to whichever table carries them.
pinnedColumn kept in an always-open card at the top of the block, picked through a select in that card's header. Must be one of featured and live on the parent table. Null for no pinned card.

Drill filter ​

new_drill_filter_block() · structured

The value filter a drill-down click writes into. One per board, beside blockr.viz's control bridge extension; senders find it by class and it resolves a claimed column to a dm table itself.

Filter dm ​

new_dm_filter_block() · structured

Filter dm by condition in any table, cascading to related tables via FKs

ArgumentDescription
tableCharacter. Name of the table within the dm where conditions are applied. Rows removed from this table cascade to related tables via the dm's FK relationships.
stateList with conditions and operator. Matches the state format of blockr.dplyr::new_filter_block - condition types values, numeric, and expr, combined with & or |.

Flatten dm ​

new_dm_flatten_block() · structured

Flatten dm into a single data frame by joining

ArgumentDescription
start_tableCharacter. Table to flatten from — becomes the left side of every join. Output row count equals this table's row count (for left joins).
include_tablesCharacter vector. Tables to join into start_table. Empty vector flattens the full dm by following all related tables.
join_typeJoin type to use throughout. One of "left" (default), "inner", "full", "right".
recursiveLogical. TRUE (default) follows multi-hop relationships through the FK graph. FALSE joins only direct neighbors of start_table.

Pull table ​

new_dm_pull_block() · structured

Extract a single table from dm as a data frame

ArgumentDescription
tableCharacter. Name of the table to extract as a data frame.

Select tables ​

new_dm_select_block() · structured

Select a subset of tables to keep in a dm

ArgumentDescription
tablesCharacter vector of table names to keep in the dm. Tables not listed are dropped. Relationships to dropped tables are removed.

Value filter ​

new_value_filter_block() · structured

Minimal value filter for a data frame or dm. Columns hidden behind the gear; per-column single vs multi select. dm input cascades via FKs.