Don't transform non-crossref links
This commit is contained in:
@@ -84,7 +84,7 @@ mtcars %>%
|
||||
<ul><li><p>By default, the pipe passes the object on its left hand side to the first argument of the function on the right-hand side. <code>%>%</code> allows you change the placement with a <code>.</code> placeholder. For example, <code>x %>% f(1)</code> is equivalent to <code>f(x, 1)</code> but <code>x %>% f(1, .)</code> is equivalent to <code>f(1, x)</code>. R 4.2.0 added a <code>_</code> placeholder to the base pipe, with one additional restriction: the argument has to be named. For example, <code>x |> f(1, y = _)</code> is equivalent to <code>f(1, y = x)</code>.</p></li>
|
||||
<li>
|
||||
<p>The <code>|></code> placeholder is deliberately simple and can’t replicate many features of the <code>%>%</code> placeholder: you can’t pass it to multiple arguments, and it doesn’t have any special behavior when the placeholder is used inside another function. For example, <code>df %>% split(.$var)</code> is equivalent to <code>split(df, df$var)</code> and <code>df %>% {split(.$x, .$y)}</code> is equivalent to <code>split(df$x, df$y)</code>.</p>
|
||||
<p>With <code>%>%</code> you can use <code>.</code> on the left-hand side of operators like <code>$</code>, <code>[[</code>, <code>[</code> (which you’ll learn about in <a href="#sec-subset-many" data-type="xref">#sec-subset-many</a>), so you can extract a single column from a data frame with (e.g.) <code>mtcars %>% .$cyl</code>. A future version of R may add similar support for <code>|></code> and <code>_</code>. For the special case of extracting a column out of a data frame, you can also use <code><a href="#chp-https://dplyr.tidyverse.org/reference/pull" data-type="xref">#chp-https://dplyr.tidyverse.org/reference/pull</a></code>:</p>
|
||||
<p>With <code>%>%</code> you can use <code>.</code> on the left-hand side of operators like <code>$</code>, <code>[[</code>, <code>[</code> (which you’ll learn about in <a href="#sec-subset-many" data-type="xref">#sec-subset-many</a>), so you can extract a single column from a data frame with (e.g.) <code>mtcars %>% .$cyl</code>. A future version of R may add similar support for <code>|></code> and <code>_</code>. For the special case of extracting a column out of a data frame, you can also use <code><a href="https://dplyr.tidyverse.org/reference/pull.html">dplyr::pull()</a></code>:</p>
|
||||
<div class="cell">
|
||||
<pre data-type="programlisting" data-code-language="downlit">mtcars |> pull(cyl)
|
||||
#> [1] 6 6 4 6 8 6 8 4 4 6 6 8 8 8 8 8 8 4 4 4 4 8 8 8 8 4 4 4 8 6 8 4</pre>
|
||||
|
||||
Reference in New Issue
Block a user