Skip to content
This repository has been archived by the owner on Aug 26, 2023. It is now read-only.

Commit

Permalink
Correct typos
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-dray committed Aug 19, 2023
1 parent dd621df commit be313f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions content/post/2023-08-19-find-bad-names.Rmd
Expand Up @@ -25,7 +25,7 @@ data[data$column == 1, ]

Oh, silly me, I tried to subset a dataframe called `data` without actually, y'know, creating it first.

This is [a classic stumbling block](https://stackoverflow.com/search?q=%22object+of+type+%27closure%27+is+not+subsettable%22+%5Br%5D) in R. In short, there's already a function in base R called `data` and so ended up trying subset it. But you can't subset a function, hence the error.
This is [a classic stumbling block](https://stackoverflow.com/search?q=%22object+of+type+%27closure%27+is+not+subsettable%22+%5Br%5D) in R. In short, there's already a function in base R called `data` and I ended up trying subset it. But you can't subset a function, hence the error.

Here's what happens if you subset a non-existent object that has a name that's different to any existing functions:

Expand Down Expand Up @@ -116,7 +116,7 @@ get_base_functions <- function() {
tail(get_base_functions())
```

Aside: this function uses a little hack. It specificaloy grabs the attached base packages from the `sessionInfo()` listing. There are other base and 'recommended' packages that are actually not attached from the start of your session; see the `Priority` value from the output of `installed.packages()`.
Aside: this function uses a little hack. It specifically grabs the attached base packages from the `sessionInfo()` listing. There are other base and 'recommended' packages that are actually not attached from the start of your session; see the `Priority` value from the output of `installed.packages()`.

Now we can run the function to check the code for the list of function names.

Expand Down
4 changes: 2 additions & 2 deletions content/post/2023-08-19-find-bad-names.html
Expand Up @@ -22,7 +22,7 @@ <h1>Naming and shaming</h1>
<pre class="r"><code>data[data$column == 1, ]</code></pre>
<pre><code>## Error in data$column: object of type &#39;closure&#39; is not subsettable</code></pre>
<p>Oh, silly me, I tried to subset a dataframe called <code>data</code> without actually, y’know, creating it first.</p>
<p>This is <a href="https://stackoverflow.com/search?q=%22object+of+type+%27closure%27+is+not+subsettable%22+%5Br%5D">a classic stumbling block</a> in R. In short, there’s already a function in base R called <code>data</code> and so ended up trying subset it. But you can’t subset a function, hence the error.</p>
<p>This is <a href="https://stackoverflow.com/search?q=%22object+of+type+%27closure%27+is+not+subsettable%22+%5Br%5D">a classic stumbling block</a> in R. In short, there’s already a function in base R called <code>data</code> and I ended up trying subset it. But you can’t subset a function, hence the error.</p>
<p>Here’s what happens if you subset a non-existent object that has a name that’s different to any existing functions:</p>
<pre class="r"><code>x[x$column == 1, ]</code></pre>
<pre><code>## Error in eval(expr, envir, enclos): object &#39;x&#39; not found</code></pre>
Expand Down Expand Up @@ -94,7 +94,7 @@ <h1>Symbolic gesture</h1>
tail(get_base_functions())</code></pre>
<pre><code>## [1] &quot;xyTable&quot; &quot;xyz.coords&quot; &quot;xzfile&quot; &quot;yinch&quot; &quot;zapsmall&quot;
## [6] &quot;zip&quot;</code></pre>
<p>Aside: this function uses a little hack. It specificaloy grabs the attached base packages from the <code>sessionInfo()</code> listing. There are other base and ‘recommended’ packages that are actually not attached from the start of your session; see the <code>Priority</code> value from the output of <code>installed.packages()</code>.</p>
<p>Aside: this function uses a little hack. It specifically grabs the attached base packages from the <code>sessionInfo()</code> listing. There are other base and ‘recommended’ packages that are actually not attached from the start of your session; see the <code>Priority</code> value from the output of <code>installed.packages()</code>.</p>
<p>Now we can run the function to check the code for the list of function names.</p>
<pre class="r"><code>naughty_words &lt;- find_var_names(
code_string = demo_code,
Expand Down

0 comments on commit be313f3

Please sign in to comment.