Skip to content

Commit

Permalink
added a few more things
Browse files Browse the repository at this point in the history
  • Loading branch information
Alathea committed Nov 4, 2014
1 parent f8a7d54 commit 10ad06a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 09_NSE/Alathea_Non-StandardEvaluation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ plyr::mutate(df, x2 = x * x, x3 = x2 * x)

### Base functions `match.fun()`, `page()`, and `ls()` all try to automatically determine whether you want standard or non-standard evaluation. Each uses a different approach. Figure out the essence of each approach then compare and contrast.

`match.fun` tests to see if the `FUN` argument is a function or character, then decides whether to use standard or non-standard evaluation.

`page` does something similar.



***

### Add an escape hatch to `plyr::mutate()` by splitting it into two functions. One function should capture the unevaluated inputs. The other should take a data frame and list of expressions and perform the computation.
Expand Down Expand Up @@ -311,5 +317,6 @@ nl <- function(...) {
* `deparse(substitute())` takes the code you typed and creates a vector out of it
* `quote`: simplified version of `substitute()`
* `eval`: opposite of `quote`
* an escape hatch: an alternative version of the function that uses standard evaluation

## Discussion Notes
3 changes: 3 additions & 0 deletions 09_NSE/Alathea_Non-StandardEvaluation.html
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ <h3>The following R functions all use NSE. For each, describe how it uses NSE, a
</div>
<div id="base-functions-match.fun-page-and-ls-all-try-to-automatically-determine-whether-you-want-standard-or-non-standard-evaluation.-each-uses-a-different-approach.-figure-out-the-essence-of-each-approach-then-compare-and-contrast." class="section level3">
<h3>Base functions <code>match.fun()</code>, <code>page()</code>, and <code>ls()</code> all try to automatically determine whether you want standard or non-standard evaluation. Each uses a different approach. Figure out the essence of each approach then compare and contrast.</h3>
<p><code>match.fun</code> tests to see if the <code>FUN</code> argument is a function or character, then decides whether to use standard or non-standard evaluation.</p>
<p><code>page</code> does something similar.</p>
<hr />
</div>
<div id="add-an-escape-hatch-to-plyrmutate-by-splitting-it-into-two-functions.-one-function-should-capture-the-unevaluated-inputs.-the-other-should-take-a-data-frame-and-list-of-expressions-and-perform-the-computation." class="section level3">
Expand Down Expand Up @@ -364,6 +366,7 @@ <h2>Reading Notes</h2>
<li><code>deparse(substitute())</code> takes the code you typed and creates a vector out of it</li>
<li><code>quote</code>: simplified version of <code>substitute()</code></li>
<li><code>eval</code>: opposite of <code>quote</code></li>
<li>an escape hatch: an alternative version of the function that uses standard evaluation</li>
</ul>
</div>
<div id="discussion-notes" class="section level2">
Expand Down
7 changes: 7 additions & 0 deletions 09_NSE/Alathea_Non-StandardEvaluation.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ plyr::mutate(df, x2 = x * x, x3 = x2 * x)

### Base functions `match.fun()`, `page()`, and `ls()` all try to automatically determine whether you want standard or non-standard evaluation. Each uses a different approach. Figure out the essence of each approach then compare and contrast.

`match.fun` tests to see if the `FUN` argument is a function or character, then decides whether to use standard or non-standard evaluation.

`page` does something similar.



***

### Add an escape hatch to `plyr::mutate()` by splitting it into two functions. One function should capture the unevaluated inputs. The other should take a data frame and list of expressions and perform the computation.
Expand Down Expand Up @@ -374,5 +380,6 @@ nl <- function(...) {
* `deparse(substitute())` takes the code you typed and creates a vector out of it
* `quote`: simplified version of `substitute()`
* `eval`: opposite of `quote`
* an escape hatch: an alternative version of the function that uses standard evaluation

## Discussion Notes

0 comments on commit 10ad06a

Please sign in to comment.