# Can't refer to columns with spaces in names in @mutate

**URL:** https://discourse.julialang.org/t/cant-refer-to-columns-with-spaces-in-names-in-mutate/123733
**Category:** New to Julia
**Tags:** dataframes
**Created:** [December 12, 2024, 12:24am UTC](https://discourse.julialang.org/t/cant-refer-to-columns-with-spaces-in-names-in-mutate/123733 "2024-12-12T00:24:51Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Geoff\_Russell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/geoff_russell/32/214126_2.png) [@Geoff\_Russell](https://discourse.julialang.org/u/Geoff_Russell)
#### Post date: [December 12, 2024, 12:24am UTC](https://discourse.julialang.org/t/cant-refer-to-columns-with-spaces-in-names-in-mutate/123733/1 "2024-12-12T00:24:51Z")

</div>

I want to do a simple mutate(a=b+c), but b and c have spaces in the names. Have tried various things without success.

using DataFrames  
using TidierData

df=DataFrame(“The Name”=\>[4,5,6],“Second Name”=\>[7,8,9])  
@chain df begin @mutate(New = “The Name” + “Second Name”)  
end  
@chain df begin @mutate(New = :“The Name” + :“Second Name”)  
end  
@chain df begin @mutate(New = Symbol(“The Name”) + Symbol(“Second Name”))  
end

Cheers,  
Geoff Russell

---

<div class="post-metadata">

### Author: ![drizk1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drizk1/32/208422_2.png) [@drizk1](https://discourse.julialang.org/u/drizk1)
#### Post date: [December 12, 2024, 2:43am UTC](https://discourse.julialang.org/t/cant-refer-to-columns-with-spaces-in-names-in-mutate/123733/2 "2024-12-12T02:43:05Z")

</div>

If you surround the name with backticks (as opposed to quotes), you will be able to to refer to a column with spaces in it

```julia
@chain df begin 
  @mutate(New = `The Name` + `Second Name`)
end
3×3 DataFrame
 Row │ The Name Second Name New   
     │ Int64 Int64 Int64 
─────┼──────────────────────────────
   1 │ 4 7 11
   2 │ 5 8 13
   3 │ 6 9 15

```

however, it may be easier to use `@clean_names` first to avoid using backticks

```julia
@chain df begin 
    @clean_names
    @mutate(New = the_name + second_name)
end
3×3 DataFrame
 Row │ the_name second_name New   
     │ Int64 Int64 Int64 
─────┼──────────────────────────────
   1 │ 4 7 11
   2 │ 5 8 13
   3 │ 6 9 15

```

---

<div class="post-metadata">

### Author: ![Geoff\_Russell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/geoff_russell/32/214126_2.png) [@Geoff\_Russell](https://discourse.julialang.org/u/Geoff_Russell)
#### Post date: [December 12, 2024, 4:26am UTC](https://discourse.julialang.org/t/cant-refer-to-columns-with-spaces-in-names-in-mutate/123733/3 "2024-12-12T04:26:45Z")

</div>

Wonderful.

Many thanks.

---

<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: [December 29, 2024, 6:27pm UTC](https://discourse.julialang.org/t/cant-refer-to-columns-with-spaces-in-names-in-mutate/123733/4 "2024-12-29T18:27:43Z")

</div>

Thanks @drizk1.

Adding to that answer, the documentation describing this capability is located here: [Column names - TidierData.jl](https://tidierorg.github.io/TidierData.jl/latest/examples/generated/UserGuide/column_names/)

---

<div class="post-metadata">

### Author: ![Geoff\_Russell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/geoff_russell/32/214126_2.png) [@Geoff\_Russell](https://discourse.julialang.org/u/Geoff_Russell)
#### Post date: [December 29, 2024, 11:25pm UTC](https://discourse.julialang.org/t/cant-refer-to-columns-with-spaces-in-names-in-mutate/123733/5 "2024-12-29T23:25:53Z")

</div>

Many thanks, that’s much clearer.
