Skip to content

Commit 6ec46a1

Browse files
committed
change image path to local
1 parent 239acf8 commit 6ec46a1

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

content/post/2023-01-30-r-basic-advanceds-variables-and-names-in-dplyr/index.Rmd

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ description: "TODO."
99
output:
1010
blogdown::html_page:
1111
toc: true
12+
images:
13+
- selection-ambiguity.png
1214
---
1315

1416
## Intro
@@ -75,7 +77,7 @@ iris %>%
7577
This generates a warning. Given the tidyverse's informative error messages, it's wise to pay heed. Directly supplying can be ambiguous -- imagine having a column named `my_variable`. Which should be selected if we have both the column and the external variable?
7678

7779

78-
![Diagram showing the dillema that dplyr is faced with when we torment it with ambiguous selections.](images/selection-ambiguity.png)
80+
![Diagram showing the dillema that dplyr is faced with when we torment it with ambiguous selections.](selection-ambiguity.png)
7981
To ensure clarity, dplyr authors suggest using dplyr::all_of(), which explicitly converts a name vector into symbols, resolving any ambiguities.
8082

8183
```{r warning=TRUE}

content/post/2023-01-30-r-basic-advanceds-variables-and-names-in-dplyr/index.html

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@
99
output:
1010
blogdown::html_page:
1111
toc: true
12+
images:
13+
- selection-ambiguity.png
1214
---
1315

1416

1517
<div id="TOC">
1618
<ul>
17-
<li><a href="#intro">Intro</a></li>
18-
<li><a href="#problem-1-symbols-vs.-strings-with-names">Problem 1: Symbols vs. strings with names</a></li>
19-
<li><a href="#problem-2-passing-column-names-as-arguments-to-custom-functions">Problem 2: Passing column names as arguments to custom functions</a></li>
20-
<li><a href="#problem-3-dynamic-columns-in-purrr-formulas-in-across">Problem 3: Dynamic columns in purrr formulas in <code>across</code></a></li>
21-
<li><a href="#summary-next-steps">Summary &amp; Next Steps</a></li>
22-
<li><a href="#dive-deeper-resources-for-the-curious-minds">Dive Deeper: Resources for the Curious Minds:</a></li>
19+
<li><a href="#intro" id="toc-intro">Intro</a></li>
20+
<li><a href="#problem-1-symbols-vs.-strings-with-names" id="toc-problem-1-symbols-vs.-strings-with-names">Problem 1: Symbols vs. strings with names</a></li>
21+
<li><a href="#problem-2-passing-column-names-as-arguments-to-custom-functions" id="toc-problem-2-passing-column-names-as-arguments-to-custom-functions">Problem 2: Passing column names as arguments to custom functions</a></li>
22+
<li><a href="#problem-3-dynamic-columns-in-purrr-formulas-in-across" id="toc-problem-3-dynamic-columns-in-purrr-formulas-in-across">Problem 3: Dynamic columns in purrr formulas in <code>across</code></a></li>
23+
<li><a href="#summary-next-steps" id="toc-summary-next-steps">Summary &amp; Next Steps</a></li>
24+
<li><a href="#dive-deeper-resources-for-the-curious-minds" id="toc-dive-deeper-resources-for-the-curious-minds">Dive Deeper: Resources for the Curious Minds:</a></li>
2325
</ul>
2426
</div>
2527

@@ -70,15 +72,18 @@ <h2>Problem 1: Symbols vs. strings with names</h2>
7072
## # Now:
7173
## data %&gt;% select(all_of(my_variables))
7274
##
73-
## See &lt;https://tidyselect.r-lib.org/reference/faq-external-vector.html&gt;.</code></pre>
75+
## See &lt;https://tidyselect.r-lib.org/reference/faq-external-vector.html&gt;.
76+
## This warning is displayed once every 8 hours.
77+
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
78+
## generated.</code></pre>
7479
<pre><code>## Sepal.Length Sepal.Width
7580
## 1 5.1 3.5
7681
## 2 4.9 3.0
7782
## 3 4.7 3.2
7883
## 4 4.6 3.1
7984
## 5 5.0 3.6</code></pre>
8085
<p>This generates a warning. Given the tidyverse’s informative error messages, it’s wise to pay heed. Directly supplying can be ambiguous – imagine having a column named <code>my_variable</code>. Which should be selected if we have both the column and the external variable?</p>
81-
<p><img src="images/selection-ambiguity.png" alt="Diagram showing the dillema that dplyr is faced with when we torment it with ambiguous selections." />
86+
<p><img src="selection-ambiguity.png" alt="Diagram showing the dillema that dplyr is faced with when we torment it with ambiguous selections." />
8287
To ensure clarity, dplyr authors suggest using dplyr::all_of(), which explicitly converts a name vector into symbols, resolving any ambiguities.</p>
8388
<pre class="r"><code>iris %&gt;%
8489
select(all_of(my_variables))</code></pre>

0 commit comments

Comments
 (0)