# Trying to understand macro scope (Tidier package)

**URL:** <https://discourse.julialang.org/t/trying-to-understand-macro-scope-tidier-package/103635>\
**Category:** General Usage\
**Created:** [September 7, 2023, 11:18pm UTC](https://discourse.julialang.org/t/trying-to-understand-macro-scope-tidier-package/103635 "2023-09-07T23:18:33Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![kdpsingh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdpsingh/32/215018_2.png) [@kdpsingh](https://discourse.julialang.org/u/kdpsingh)\
**Post date:** [September 11, 2023, 1:26pm UTC](https://discourse.julialang.org/t/trying-to-understand-macro-scope-tidier-package/103635/22 "2023-09-11T13:26:40Z")

</div>

Actually, you can wrap this inside of an anonymous function where you call the anonymous function as soon as define it with a `(x -> fn(x))(arg1, arg2)` syntax.

Here’s the short version.

```julia
@chain df begin
  @mutate(a_label = ~categorical((x -> @sprintf("Var = %.1f", x))(a)))
end

```

…and here I’ve broken it up into 2 steps for readability…

```julia
@chain df begin
  @mutate(a_label = (x -> @sprintf("Var = %.1f", x))(a))
  @mutate(a_label = ~categorical(a_label))
end

```

Anonymous functions in TidierData.jl should mostly only be needed in situations where your code uses macros (or where you’re using `across()`).

[Previous page](https://discourse.julialang.org/t/trying-to-understand-macro-scope-tidier-package/103635.md?page=1)
