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.

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 (default) removes duplicated subject-level columns (AGE, SEX, ARM, etc.) from non-ADSL tables so they live only on ADSL. Avoids column-name collisions in downstream joins.

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.
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.

DM Example

new_dm_example_block() · structured

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 ...

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).

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 |.

Filter dm by data

new_dm_filter_by_data_block() · structured

Semi-join a dm to ids supplied by a second data frame input, cascading via FKs

ArgumentDescription
tableCharacter. Name of the dm table to filter. Rows whose key_col value is absent from by[[key_col]] are dropped; matching rows cascade to related tables via FKs. Default "adsl".
key_colCharacter. Column used for the match. Must exist in both by (the second input data frame) and table (the selected dm table). Default "USUBJID".
distinct_onlyLogical. TRUE (default) deduplicates by[[key_col]] before matching. FALSE passes the raw column through.

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.

Nested view

new_dm_nested_view_block() · structured

Display dm as nested table with expandable rows

ArgumentDescription
root_tableCharacter vector. Root table(s) to render at the top level. Child tables are shown as expandable rows via FK relationships.

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.

Read dm

new_dm_read_block() · structured

Read tables from Excel, ZIP, or directory into 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.

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() · structured

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.