Skip to content

blockr.dplyr

Data wrangling, one block per verb: filter, select, mutate, summarize, join, pivot and friends. If you would reach for dplyr in R, you reach for these blocks in blockr.

Arrange Rows

new_arrange_block() · transform

Sort rows by one or more columns, ascending or descending. (dplyr: arrange)

ArgumentDescription
columnsArray of {column, direction} objects where direction is "asc" or "desc". Rows are sorted by the columns in order.

Bind Columns

new_bind_cols_block() · transform

Place tables side-by-side horizontally. Both must have the same number of rows. (dplyr: bind_cols)

Bind Rows

new_bind_rows_block() · transform

Stack tables vertically by matching column names. (dplyr: bind_rows)

ArgumentDescription
id_nameOptional string -- name of an .id column identifying which input each row came from

Filter Rows

new_filter_block() · transform

Keep or remove rows by values, comparisons, or expressions. (dplyr: filter)

ArgumentDescription
conditionsArray of condition objects. Types: "values" (column, values array of strings, mode "include"/"exclude"), "numeric" (column, op like ">"/">="/"<"/"<=", value as number), "expr" (expr as R expression string)
operatorHow to combine conditions: "&" for AND (all match), "|" for OR (any match)
preserve_orderBoolean -- when true, keep the original row order rather than reordering

Join

new_join_block() · transform

Combine two tables by matching values in shared columns. Left, inner, right, full, anti, semi joins. (dplyr: *_join)

ArgumentDescription
typeJoin type string: left_join, inner_join, right_join, full_join, anti_join, or semi_join
keysArray of {xCol, op, yCol} objects defining the column pairs to match
exprsArray of R expression strings (optional, advanced join predicates)
suffix_xSuffix added to overlapping column names from the left table (default '.x')
suffix_ySuffix added to overlapping column names from the right table (default '.y')

Mutate Columns

new_mutate_block() · transform

Add new columns or transform existing ones using R expressions. (dplyr: mutate)

ArgumentDescription
mutationsArray of objects, each with 'name' (new column name) and 'expr' (R expression string)
byOptional array of grouping column names (group the operation, e.g. mean per group)

Pivot Longer

new_pivot_longer_block() · transform

Reshape wide data to long — gather columns into rows. (tidyr: pivot_longer)

ArgumentDescription
colsArray of column names to pivot to long form
names_toString -- name of the new column holding the pivoted names
values_toString -- name of the new column holding the pivoted values
values_drop_naBoolean -- drop rows with NA values after pivoting
names_prefixString -- regex prefix stripped from the pivoted names

Pivot Wider

new_pivot_wider_block() · transform

Reshape long data to wide — spread rows into columns. (tidyr: pivot_wider)

ArgumentDescription
names_fromArray of column(s) whose values become the new column names
values_fromArray of column(s) whose values fill the new columns
id_colsArray (optional) of columns that uniquely identify each output row
values_fillValue (or null) used to fill missing cells
names_sepString separator joining multiple names_from / prefix parts
names_prefixString prepended to every new column name
values_fnString (or null) aggregation function (e.g. 'mean', 'sum', 'first') for duplicate id+name combinations

Rename

new_rename_block() · transform

Change column names without modifying data. (dplyr: rename)

ArgumentDescription
renamesObject mapping new names to old names: {new_name: 'old_name', ...}. Keys are the desired new column names, values are the existing column names.

Select Columns

new_select_block() · transform

Choose, reorder, or exclude columns. Optionally remove duplicate rows. (dplyr: select, distinct)

ArgumentDescription
columnsArray of column name strings to keep (or to remove, when exclude=true)
excludeBoolean -- when true, drop the listed columns instead of keeping them
distinctBoolean -- when true, deduplicate rows after selecting

Separate Column

new_separate_block() · transform

Split one column into multiple columns using a delimiter. (tidyr: separate)

ArgumentDescription
colSource column to split
intoArray of new column names to split into
sepSeparator string (or regex) to split on
removeBoolean -- remove the source column after splitting
convertBoolean -- auto-convert the new columns to numeric/logical types

Slice Rows

new_slice_block() · transform

Pick rows by position, random sample, or min/max of a column. (dplyr: slice)

ArgumentDescription
typeOne of 'head' (first n rows), 'tail' (last n), 'min'/'max' (rows with smallest/largest order_by values), 'sample' (random sample)
nInteger row count
propNumber 0-1, proportion of rows (alternative to n -- not both)
order_byColumn to rank by, for min/max
with_tiesBoolean -- whether tied rows at the cutoff are all kept (min/max)
weight_byColumn of weights, for sampling
replaceBoolean -- sample with replacement
byArray of grouping columns (slice within each group)

Summarize

new_summarize_block() · transform

Calculate totals, averages, counts, and other statistics, optionally by group. (dplyr: summarize)

ArgumentDescription
summariesArray of summary objects. Types: 'simple' (name, func like 'mean'/'sd'/'sum'/'n'/'n_distinct', col) or 'expr' (name, expr as R expression string)
byArray of grouping column names -- this is how you group (do NOT write group_by() in exprs)

Unite Columns

new_unite_block() · transform

Merge multiple columns into one by pasting values together. (tidyr: unite)

ArgumentDescription
colNew column name for the united result
colsArray of columns to unite
sepSeparator string placed between values
removeBoolean -- remove the input columns after uniting
na_rmBoolean -- drop NA values before uniting