Skip to content

Commit

Permalink
Fixed documentation error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Karandeep Singh committed Dec 12, 2023
1 parent a7713c7 commit 171d6af
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/examples/UserGuide/interpolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,21 @@ df = DataFrame(radius = 1:5)
@mutate(area = !!pi * radius^2)
end

# ## Alternative interpolation syntax

# While interpolation using `!!` is concise and handy, it's not required. You can also access user-defined globals and global constant variables using the following syntax:
# As of v0.14.0, global constants defined within the Base or Core modules (like `missing`, `pi`, and `Real` can be directly referenced without any `!!`)

@chain df begin
@mutate(area = esc(pi) * radius^2)
@mutate(area = pi * radius^2)
end

# ## Alternative interpolation syntax

# Since we know that `pi` is defined in the `Main` module, we can also access it using `Main.pi`.

@chain df begin
@mutate(area = Main.pi * radius^2)
end

# The key lesson with interpolation is that any bare unquoted variable is assumed to refer to a column name in the DataFrame. If you are referring to any variable outside of the DataFrame, you need to either use `!!variable`, `esc(variable)`, or `[Module_name_here].variable` syntax to refer to this variable.
# The key lesson with interpolation is that any bare unquoted variable is assumed to refer to a column name in the DataFrame. If you are referring to any variable outside of the DataFrame, you need to either use `!!variable` or `[Module_name_here].variable` syntax to refer to this variable.

# Note: You can use `!!` interpolation anywhere, including inside of functions and loops.

Expand Down

0 comments on commit 171d6af

Please sign in to comment.