Skip to content

Feature Request: str_replace(), str_replace_all() like renaming within cols_label() to apply across as many columns as applicable #701

Closed

Description

@ScoobyQ

I would like to see cols_label support multi-column renames using pattern matching and specified replacement strings for matches much like str_replace, str_replace_all.

If I had columns such as: c1_mean_2019-20, c1_mean_2020-21, I would like to be able to replace c1_mean_ with '', leaving 2019-20, 2020-21. This needs to happen IN the gt object.

Something like:

cols_label( contains('c1_mean_') = str_replace(contains('c1_mean_'),'c1_mean_', '') )

Looking at cols_label this functionality does not appear to exist.

Activity

  1. rich-iannone commented on Apr 27, 2021

    @rich-iannone
    Member

    This is a good idea! Could work in the form of

    cols_label(contains("...") = ~ fn(.))

    So that any string manipulation functions would work. We'd have to also ensure that helpers such as md(), html(), etc., continue to work in this form

    cols_label(contains("...") = md(~ fn(.)))

    and this

    cols_label(contains("...") = ~ md(fn(.)))
  2. self-assigned this
    on Apr 27, 2021
  3. added this to the v0.4.0 milestone on Apr 27, 2021
  4. modified the milestones: v0.4.0, v0.5.0 on Jan 26, 2022
  5. modified the milestones: v0.5.0, v0.6.0 on Mar 1, 2022
  6. modified the milestones: v0.6.0, v0.7.0 on Apr 19, 2022
  7. modified the milestones: v0.7.0, v0.8.0 on Jul 7, 2022
  8. changed the title [-]Feature Request: str_replace, str_replace_all like renaming within cols_label to apply across as many columns as applicable[/-] [+]Feature Request: `str_replace()`, `str_replace_all()` like renaming within `cols_label()` to apply across as many columns as applicable[/+] on Aug 26, 2022
  9. modified the milestones: v0.8.0, FUTURE on Sep 22, 2022
  10. rich-iannone commented on Dec 5, 2022

    @rich-iannone
    Member

    Fixed by #1158.

  11. moved this from Backlog to Done in R Markdown Team Projectson Dec 17, 2022
  12. modified the milestones: FUTURE, v0.9.0 on Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions