Skip to content

Better Handling of Formatting Anonymous Functions that are Piped to? #412

@emstruong

Description

@emstruong

Hello,

I was wondering if there air could better format the following piece of code?

correction_factor <- fitted.values(mod) |>
          {\(y_hat) (exp(y_hat) - 1)}() |>
          {\(y_hat_back_transformed) {
              lm(df$deaths ~ y_hat_back_transformed - 1)
            }}() |>
          {\(fitted_model) coef(fitted_model)}() |>
          {\(named_coef) unname(named_coef)}()

I'm running air 0.7.0 and it formats it this way, which I think is arguably harder to read because there's so much clutter separating the informative pieces of information

correction_factor <- fitted.values(mod) |>
  {
    \(y_hat) (exp(y_hat) - 1)
  }() |>
  {
    \(y_hat_back_transformed) {
      lm(df$deaths ~ y_hat_back_transformed - 1)
    }
  }() |>
  {
    \(fitted_model) coef(fitted_model)
  }() |>
  {
    \(named_coef) unname(named_coef)
  }()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions