Skip to content

Conversation

@alex-lauer
Copy link
Collaborator

Summary

Hi @rich-iannone,

had to open this PR because I finally found a way to get rid of my last magrittr pipe in the context of purrr and yet still keep my code structure kind of clean:

### Changed 

adsl_summary <- purrr::[map_df](https://purrr.tidyverse.org/reference/map_dfr.html)(
      .x = dplyr::[vars](https://dplyr.tidyverse.org/reference/vars.html)(AGE, AAGEGR1, SEX, ETHNIC, BLBMI),
      .f = \(x) custom_summary(df = dplyr::[filter](https://dplyr.tidyverse.org/reference/filter.html)(rx_adsl, ITTFL == "Y"), group_var = TRTA, sum_var = !!x)
    )

### to:
adsl_summary <- dplyr::filter(rx_adsl, ITTFL == "Y") |> 
  (\(data) purrr::map_df(
    .x = dplyr::vars(AGE, AAGEGR1, SEX, ETHNIC, BLBMI),
    .f = \(x) custom_summary(df = data, group_var = TRTA, sum_var = !!x)
  ))()

Checklist

Finally found out how to get rid of my last magrittr pipe (and still separate the filter step from map_df).
@alex-lauer
Copy link
Collaborator Author

The first piece of code was copied from the article in dev. Sorry for the display.

Copy link
Member

@rich-iannone rich-iannone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@rich-iannone
Copy link
Member

Merging now. Thank you!

@rich-iannone rich-iannone merged commit 7b547e7 into rstudio:master Feb 17, 2023
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.

2 participants