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), "safetydata_adam" / "pharmaverseadam" / "bms_adam" (CDISC ADaM clinical dm with adsl, adae, ...), "pharmaversesdtm" (raw ...

Import multiple tables ​

new_dm_read_block() · input

Read a whole directory, ZIP archive or Excel workbook at once: one table per file or sheet, linked as a dm

ArgumentDescription
pathCharacter. Path to a file or directory to read. Supported: .xlsx / .xls (one sheet per table), .zip of per-table files, or a directory containing per-table CSV / Parquet / Feather files.
selected_tablesOptional character vector restricting which tables to load. null or unset loads every table found at path.
argsNamed list of reader options applied uniformly to every member of the container; each member's format picks the parameters it understands (e.g. list(sep = ";") reads every CSV in the folder as semicolon-separated an...

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.

CDISC dm ​

new_cdisc_dm_block() · structured

Set CDISC keys (USUBJID PK/FK) and optionally deduplicate subject columns

ArgumentDescription
set_keysLogical. TRUE (default) sets USUBJID as primary key on ADSL and foreign key on all other tables. Required for any cascading dm filter to work.
dedup_colsLogical. TRUE removes duplicated subject-level columns (AGE, SEX, ARM, etc.) from non-ADSL tables so they live only on ADSL, which avoids column-name collisions in downstream joins. FALSE (the default) leaves every ta...

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.

dm Temporal join ​

new_dm_temporal_join_block() · structured

Temporal join between two dm tables, filtering by time window

ArgumentDescription
left_tableCharacter. Name of the "anchor" table in the dm.
left_dateCharacter. Date/datetime column on left_table that defines the anchor time (e.g. treatment start).
right_tableCharacter. Name of the "event" table in the dm being joined in.
right_dateCharacter. Date/datetime column on right_table whose offset from left_date is checked against the window.
window_daysInteger. Size of the time window in days (default 7).
directionWindow direction relative to left_date. One of "after" (default, keep events within window_days AFTER anchor), "before", or "around" (two-sided window).

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.

Temporal join ​

new_temporal_join_block() · structured

Join two tables and filter by time window between date columns

ArgumentDescription
byCharacter vector of column names to match on as the join key (e.g. subject ID). Rows with matching key AND date-within-window are joined.
left_dateCharacter. Date column on the LEFT (x) table that defines the anchor time.
right_dateCharacter. Date column on the RIGHT (y) table whose offset from left_date is checked against the window.
window_daysInteger. Window size in days. Default 7.
directionWindow direction relative to left_date. One of "after" (default), "before", "around".

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.

Write dm ​

new_dm_write_block() · output

Write dm object to Excel, ZIP, or directory

ArgumentDescription
directoryCharacter. Output directory path.
filenameCharacter. Base filename (no extension). Extension is derived from format. For Excel, one file; for CSV / Parquet, one file per table.
formatOutput format. One of "excel", "csv", or "parquet". Default "excel".
auto_writeLogical. TRUE writes on every upstream update; FALSE (default) writes only on explicit action.