Skip to content

Add the fmt_chem() function#1636

Merged
rich-iannone merged 41 commits intomasterfrom
fmt-chem-add
Apr 25, 2024
Merged

Add the fmt_chem() function#1636
rich-iannone merged 41 commits intomasterfrom
fmt-chem-add

Conversation

@rich-iannone
Copy link
Member

With fmt_chem() it's possible to format chemical formulas and chemical equations. The markup necessary for this is called gt's chemistry notation. One example of fmt_chem() usage is in this example:

reactions |>
  dplyr::filter(cmpd_type == "terminal monoalkene") |>
  dplyr::filter(grepl("^1-", cmpd_name)) |>
  dplyr::select(cmpd_name, cmpd_formula, ends_with("k298")) |>
  gt() |>
  sub_missing() |>
  fmt_chem(columns = cmpd_formula) |>
  fmt_scientific() |>
  cols_label(
    cmpd_name = "Alkene",
    cmpd_formula = "Formula",
    oh_k298 = "OH",
    o3_k298 = "{{%O3%}}",
    no3_k298 = "{{%NO3%}}",
    cl_k298 = "Cl"
  ) |>
  tab_spanner(
    label = "Reaction Rate Constant at 298 K",
    columns = ends_with("k298")
  ) |>
  tab_header(title = "Gas-phase reactions of selected terminal alkenes") |>
  opt_align_table_header(align = "left")
reactions_table

@rich-iannone rich-iannone marked this pull request as ready for review April 25, 2024 21:27
@rich-iannone rich-iannone merged commit bcf2b71 into master Apr 25, 2024
@rich-iannone rich-iannone deleted the fmt-chem-add branch April 25, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant