Skip to content

Commit 3923e2a

Browse files
authored
Correct display of embracing operator (#1675)
Quarto supports inline code using the backtick operator [1], using backticks and curly quotes to specify the engine. Because of this, `{{ }}` is apparently parsed as inline code and renders as `{ }`. An extra level of curly braces must be added to display the embracing operator in the text. [1]: https://quarto.org/docs/computations/inline-code.html
1 parent 065cb32 commit 3923e2a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

functions.qmd

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ But you'll often also repeat the verbs themselves, particularly within a large p
351351
When you notice yourself copying and pasting multiple verbs multiple times, you might think about writing a data frame function.
352352
Data frame functions work like dplyr verbs: they take a data frame as the first argument, some extra arguments that say what to do with it, and return a data frame or a vector.
353353
354-
To let you write a function that uses dplyr verbs, we'll first introduce you to the challenge of indirection and how you can overcome it with embracing, `{{ }}`.
354+
To let you write a function that uses dplyr verbs, we'll first introduce you to the challenge of indirection and how you can overcome it with embracing, `{{{ }}}`.
355355
With this theory under your belt, we'll then show you a bunch of examples to illustrate what you might do with it.
356356
357357
### Indirection and tidy evaluation
@@ -398,11 +398,11 @@ The downside of tidy evaluation comes when we want to wrap up repeated tidyverse
398398
Here we need some way to tell `group_by()` and `summarize()` not to treat `group_var` and `mean_var` as the name of the variables, but instead look inside them for the variable we actually want to use.
399399

400400
Tidy evaluation includes a solution to this problem called **embracing** 🤗.
401-
Embracing a variable means to wrap it in braces so (e.g.) `var` becomes `{{ var }}`.
401+
Embracing a variable means to wrap it in braces so (e.g.) `var` becomes `{{{ var }}}`.
402402
Embracing a variable tells dplyr to use the value stored inside the argument, not the argument as the literal variable name.
403-
One way to remember what's happening is to think of `{{ }}` as looking down a tunnel --- `{{ var }}` will make a dplyr function look inside of `var` rather than looking for a variable called `var`.
403+
One way to remember what's happening is to think of `{{{ }}}` as looking down a tunnel --- `{{{ var }}}` will make a dplyr function look inside of `var` rather than looking for a variable called `var`.
404404

405-
So to make `grouped_mean()` work, we need to surround `group_var` and `mean_var` with `{{ }}`:
405+
So to make `grouped_mean()` work, we need to surround `group_var` and `mean_var` with `{{{ }}}`:
406406

407407
```{r}
408408
grouped_mean <- function(df, group_var, mean_var) {
@@ -782,7 +782,7 @@ rlang is a low-level package that's used by just about every other package in th
782782

783783
To solve the labeling problem we can use `rlang::englue()`.
784784
This works similarly to `str_glue()`, so any value wrapped in `{ }` will be inserted into the string.
785-
But it also understands `{{ }}`, which automatically inserts the appropriate variable name:
785+
But it also understands `{{{ }}}`, which automatically inserts the appropriate variable name:
786786

787787
```{r}
788788
#| fig-alt: |
@@ -861,7 +861,7 @@ density <- function(color, facets, binwidth = 0.1) {
861861
}
862862
```
863863

864-
As you can see we recommend putting extra spaces inside of `{{ }}`.
864+
As you can see we recommend putting extra spaces inside of `{{{ }}}`.
865865
This makes it very obvious that something unusual is happening.
866866

867867
### Exercises

0 commit comments

Comments
 (0)