Skip to content

Commit

Permalink
rebuilt reader
Browse files Browse the repository at this point in the history
  • Loading branch information
wes-brooks committed Feb 1, 2024
1 parent dc3d5a8 commit 1ee0469
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
Binary file modified docs/04_debugging_files/figure-html/first-case-study-plot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/04_debugging_files/figure-html/fixed-resample-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/04_debugging_files/figure-html/sex-and-species-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/05_visualization_files/figure-html/example-genotype-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 deletions docs/language-fundamentals.html
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ <h3><span class="header-section-number">6.1.1</span> What’s an Environment?<a
<p>You can use the <code>new.env</code> function to create a new environment:</p>
<div class="sourceCode" id="cb490"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb490-1"><a href="language-fundamentals.html#cb490-1" tabindex="-1"></a>e <span class="ot">=</span> <span class="fu">new.env</span>()</span>
<span id="cb490-2"><a href="language-fundamentals.html#cb490-2" tabindex="-1"></a>e</span></code></pre></div>
<pre><code>## &lt;environment: 0x7fe9410e3ec8&gt;</code></pre>
<pre><code>## &lt;environment: 0x7f7ae2b6cec8&gt;</code></pre>
<p>Unlike most objects, printing an environment doesn’t print its contents.
Instead, R prints its type (which is <code>environment</code>) and a unique identifier
(<code>0x7fe9410e3ec8</code> in this case).</p>
(<code>0x7f7ae2b6cec8</code> in this case).</p>
<p>The unique identifier is actually the <strong>memory address</strong> of the environment.
Every object you use in R is stored as a series of <a href="https://en.wikipedia.org/wiki/Byte">bytes</a> in your computer’s
<a href="https://en.wikipedia.org/wiki/Random-access_memory">random-access memory (RAM)</a>. Each byte in memory has a unique address,
Expand Down Expand Up @@ -565,7 +565,7 @@ <h3><span class="header-section-number">6.1.4</span> Call Environments<a href="l
<p>The call environment is not the global environment:</p>
<div class="sourceCode" id="cb544"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb544-1"><a href="language-fundamentals.html#cb544-1" tabindex="-1"></a>e <span class="ot">=</span> <span class="fu">my_hello</span>()</span>
<span id="cb544-2"><a href="language-fundamentals.html#cb544-2" tabindex="-1"></a>e</span></code></pre></div>
<pre><code>## &lt;environment: 0x7fe93cbe28d0&gt;</code></pre>
<pre><code>## &lt;environment: 0x7f7aebc538d0&gt;</code></pre>
<p>And the variable <code>hello</code> exists in the call environment, but not in the global
environment:</p>
<div class="sourceCode" id="cb546"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb546-1"><a href="language-fundamentals.html#cb546-1" tabindex="-1"></a><span class="fu">exists</span>(<span class="st">&quot;hello&quot;</span>, g)</span></code></pre></div>
Expand All @@ -579,9 +579,9 @@ <h3><span class="header-section-number">6.1.4</span> Call Environments<a href="l
memory address):</p>
<div class="sourceCode" id="cb552"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb552-1"><a href="language-fundamentals.html#cb552-1" tabindex="-1"></a>e2 <span class="ot">=</span> <span class="fu">my_hello</span>()</span>
<span id="cb552-2"><a href="language-fundamentals.html#cb552-2" tabindex="-1"></a>e</span></code></pre></div>
<pre><code>## &lt;environment: 0x7fe93cbe28d0&gt;</code></pre>
<pre><code>## &lt;environment: 0x7f7aebc538d0&gt;</code></pre>
<div class="sourceCode" id="cb554"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb554-1"><a href="language-fundamentals.html#cb554-1" tabindex="-1"></a>e2</span></code></pre></div>
<pre><code>## &lt;environment: 0x7fe9445c1730&gt;</code></pre>
<pre><code>## &lt;environment: 0x7f7aebf5ef30&gt;</code></pre>
<p>By creating a new environment for every call, R isolates code in the function
body from code outside of the body. As a result, most R functions have no
<strong>side effects</strong>. This is a good thing, since it means you generally don’t have
Expand Down Expand Up @@ -832,7 +832,7 @@ <h4><span class="header-section-number">6.1.7.1</span> The Colon Operators<a hre
## else &quot;ts&quot;
## y
## }
## &lt;bytecode: 0x7fe93cb9e2b0&gt;
## &lt;bytecode: 0x7f7aebc0f2b0&gt;
## &lt;environment: namespace:stats&gt;</code></pre>
<div class="sourceCode" id="cb599"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb599-1"><a href="language-fundamentals.html#cb599-1" tabindex="-1"></a>dplyr<span class="sc">::</span>filter</span></code></pre></div>
<pre><code>## function (.data, ..., .by = NULL, .preserve = FALSE)
Expand All @@ -844,14 +844,14 @@ <h4><span class="header-section-number">6.1.7.1</span> The Colon Operators<a hre
## }
## UseMethod(&quot;filter&quot;)
## }
## &lt;bytecode: 0x7fe93f262350&gt;
## &lt;bytecode: 0x7f7ae2b3e950&gt;
## &lt;environment: namespace:dplyr&gt;</code></pre>
<div class="sourceCode" id="cb601"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb601-1"><a href="language-fundamentals.html#cb601-1" tabindex="-1"></a>ggplot2<span class="sc">::</span>ggplot</span></code></pre></div>
<pre><code>## function (data = NULL, mapping = aes(), ..., environment = parent.frame())
## {
## UseMethod(&quot;ggplot&quot;)
## }
## &lt;bytecode: 0x7fe93fe57e38&gt;
## &lt;bytecode: 0x7f7ae9f6a638&gt;
## &lt;environment: namespace:ggplot2&gt;</code></pre>
<p>The related triple-colon operator <code>:::</code> gets a <strong>private</strong> variable in a
package. Generally these are private for a reason! Only use <code>:::</code> if you’re
Expand Down Expand Up @@ -1096,13 +1096,13 @@ <h3><span class="header-section-number">6.4.1</span> Method Dispatch<a href="lan
<div class="sourceCode" id="cb636"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb636-1"><a href="language-fundamentals.html#cb636-1" tabindex="-1"></a>split</span></code></pre></div>
<pre><code>## function (x, f, drop = FALSE, ...)
## UseMethod(&quot;split&quot;)
## &lt;bytecode: 0x7fe941aa3fe0&gt;
## &lt;bytecode: 0x7f7ae65f07e0&gt;
## &lt;environment: namespace:base&gt;</code></pre>
<p>Another is the <code>plot</code> function, which creates a plot:</p>
<div class="sourceCode" id="cb638"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb638-1"><a href="language-fundamentals.html#cb638-1" tabindex="-1"></a>plot</span></code></pre></div>
<pre><code>## function (x, y, ...)
## UseMethod(&quot;plot&quot;)
## &lt;bytecode: 0x7fe941d360f8&gt;
## &lt;bytecode: 0x7f7ae9bc8ef8&gt;
## &lt;environment: namespace:base&gt;</code></pre>
<p>The <code>UseMethod</code> function requires the name of the generic (as a string) as its
first argument. The second argument is optional and specifies the object to use
Expand Down Expand Up @@ -1131,7 +1131,7 @@ <h3><span class="header-section-number">6.4.1</span> Method Dispatch<a href="lan
## lapply(split(x = seq_len(nrow(x)), f = f, drop = drop, ...),
## function(ind) x[ind, , drop = FALSE])
## }
## &lt;bytecode: 0x7fe93f1ef1b0&gt;
## &lt;bytecode: 0x7f7ae4c64fb0&gt;
## &lt;environment: namespace:base&gt;</code></pre>
<p>Sometimes methods are defined in privately packages and can’t be accessed by
typing their name at the prompt. You can use the <code>getAnywhere</code> function to get
Expand Down Expand Up @@ -1164,7 +1164,7 @@ <h3><span class="header-section-number">6.4.1</span> Method Dispatch<a href="lan
## pairs(data.matrix(x), ...)
## }
## }
## &lt;bytecode: 0x7fe941de41f8&gt;
## &lt;bytecode: 0x7f7ae9c7e830&gt;
## &lt;environment: namespace:graphics&gt;</code></pre>
<p>As a demonstration of method dispatch, consider this code to split the <code>mtcars</code>
dataset by number of cylinders:</p>
Expand Down
2 changes: 1 addition & 1 deletion docs/search_index.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/squashing-bugs-with-rs-debugging-tools.html
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ <h2><span class="header-section-number">4.3</span> Global Options<a href="squash
## cli_server_default(msg)
## }
## }
## &lt;bytecode: 0x7ff473f65368&gt;
## &lt;bytecode: 0x7fa666654368&gt;
## &lt;environment: namespace:cli&gt;
##
## $CBoundsCheck
Expand Down Expand Up @@ -844,7 +844,7 @@ <h4><span class="header-section-number">4.4.6.1</span> Fixing The Bug<a href="sq
## 2: stack(bootstrap(data, B = B, ...)) at debug_case_study.R#60
## 1: make_bootstrap_plots(penguins, &quot;species&quot;, &quot;island&quot;)</code></pre>
<p>The error is generated in the <code>resample()</code> function, which is one of the functions in the script you downloaded. You can identify which line of that code matches the code reported in the error message, which tells us that the error is generated on line 13 of <code>debug_case_study.R</code>.</p>
<p>Remember tha the location of an error and the cause of the error are not always the same thing. To try and understand the cause of the error, let’s start the debugger by putting a <code>browser()</code> call just before line 13, like this:</p>
<p>Remember that the location of an error and the cause of the error are not always the same thing. To try and understand the cause of the error, let’s start the debugger by putting a <code>browser()</code> call just before line 13, like this:</p>
<div class="sourceCode" id="cb451"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb451-1"><a href="squashing-bugs-with-rs-debugging-tools.html#cb451-1" tabindex="-1"></a>resample <span class="ot">=</span> <span class="cf">function</span>(data, B) {</span>
<span id="cb451-2"><a href="squashing-bugs-with-rs-debugging-tools.html#cb451-2" tabindex="-1"></a> N <span class="ot">=</span> <span class="fu">length</span>(data)</span>
<span id="cb451-3"><a href="squashing-bugs-with-rs-debugging-tools.html#cb451-3" tabindex="-1"></a> result <span class="ot">=</span> <span class="fu">numeric</span>(B)</span>
Expand Down Expand Up @@ -1050,8 +1050,8 @@ <h3><span class="header-section-number">4.5.2</span> Benchmarking<a href="squash
<span id="cb468-2"><a href="squashing-bugs-with-rs-debugging-tools.html#cb468-2" tabindex="-1"></a><span class="fu">microbenchmark</span>(<span class="at">A =</span> <span class="fu">runif</span>(<span class="fl">1e5</span>), <span class="at">B =</span> <span class="fu">rnorm</span>(<span class="fl">1e5</span>))</span></code></pre></div>
<pre><code>## Unit: milliseconds
## expr min lq mean median uq max neval cld
## A 1.222137 1.551553 1.918578 1.897681 2.134616 5.410240 100 a
## B 3.911026 4.473120 5.264633 5.162160 6.039717 9.846878 100 b</code></pre>
## A 1.289372 1.561523 1.844360 1.761270 2.012996 5.612642 100 a
## B 4.102926 4.568713 5.246599 5.189999 5.751217 9.335760 100 b</code></pre>
<p>The <code>microbenchmark</code> has parameters to control the number of times each
expression runs, the units for the timings, and more. You can find the details
in <code>?microbenchmark</code>.</p>
Expand Down

0 comments on commit 1ee0469

Please sign in to comment.