# Is there an equivalent to dplyr::across

**URL:** <https://discourse.julialang.org/t/is-there-an-equivalent-to-dplyr-across/48129>\
**Category:** General Usage\
**Tags:** dataframes\
**Created:** [October 10, 2020, 9:05pm UTC](https://discourse.julialang.org/t/is-there-an-equivalent-to-dplyr-across/48129 "2020-10-10T21:05:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derek\_Vetsch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/derek_vetsch/32/8552_2.png) [@Derek\_Vetsch](https://discourse.julialang.org/u/Derek_Vetsch)\
**Post date:** [October 10, 2020, 9:05pm UTC](https://discourse.julialang.org/t/is-there-an-equivalent-to-dplyr-across/48129/1 "2020-10-10T21:05:51Z")

</div>

So I am trying to switch my employer’s credit modeling code base over to Julia but am running into issues with wide datasets. In R you can apply a function to multiple columns columnwise, for example using `dplyr` to square each column except species you could do something like this:

```julia
iris %>%
     mutate(
          across(
               !(contains("Species")),
                function(x) {x^2}
         )
     )

```

Is there an equivalent style of operation to this in `DataFrames`?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [October 10, 2020, 9:36pm UTC](https://discourse.julialang.org/t/is-there-an-equivalent-to-dplyr-across/48129/2 "2020-10-10T21:36:59Z")

</div>

You can use `names(df, Not(r"species"))` to get all the columns that dont contain species.

Then you can broadcast the function `t -> t^2` across this vector to get a vector of pairs. Then use this as an input to `transform`.

```julia

 transform(df, names(df,Not(r"species")) .=> ByRow(t -> t^2))

```

PS [this comparison](https://juliadata.github.io/DataFrames.jl/latest/man/comparisons/#Comparison-with-the-R-package-dplyr) in the latest version of the DataFrames documentation will be really useful.

---

<div class="post-metadata">

**Author:** ![Derek\_Vetsch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/derek_vetsch/32/8552_2.png) [@Derek\_Vetsch](https://discourse.julialang.org/u/Derek_Vetsch)\
**Post date:** [October 11, 2020, 12:04am UTC](https://discourse.julialang.org/t/is-there-an-equivalent-to-dplyr-across/48129/3 "2020-10-11T00:04:59Z")

</div>

That comparison is a game changer. Thanks
