| wide_pivot_first | R Documentation |
Internal helper used by get_cheminfo to replace
tidyr::pivot_wider(..., values_fn = dplyr::first, values_fill = NA)
with a much faster matrix-based implementation. tidyr's pivot_wider incurs
substantial overhead from its generic duplicate-handling/values_fn
machinery, which dominates runtime on httk's larger chemprop table
(~167k rows); this function gives an identical result (one row per
distinct id, one column per distinct name, first value kept for
duplicated id/name pairs, NA for missing combinations) much faster.
wide_pivot_first(data, id_col, name_col, value_col)
data |
A long-format data frame with id, name, and value columns. |
id_col |
Name of the column identifying each output row. |
name_col |
Name of the column whose distinct values become output column names. |
value_col |
Name of the column supplying output cell values. |
A data frame with one row per distinct value of id_col
and one column per distinct value of name_col.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.