Skip to content

Commit

Permalink
Deploying to gh-pages from @ 216bbc7 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Oct 13, 2024
1 parent b051378 commit 26008f6
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 110 deletions.
2 changes: 1 addition & 1 deletion book-asciidoc/dependencies-mindset-background.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ sd
#> function (x, na.rm = FALSE)
#> sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x),
#> na.rm = na.rm))
#> <bytecode: 0x55b0ac8d14d0>
#> <bytecode: 0x564ec2bf2888>
#> <environment: namespace:stats>
----

Expand Down
10 changes: 5 additions & 5 deletions book-asciidoc/package-within.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Finally, this cleaned (cleaner?) data is written back out to a CSV file. They li
now <- Sys.time()
timestamp <- format(now, "%Y-%B-%d_%H-%M-%S")
(outfile <- paste0(timestamp, "_", sub("(.*)([.]csv$)", "\\1_clean\\2", infile)))
#> [1] "2024-October-12_07-14-20_swim_clean.csv"
#> [1] "2024-October-13_07-14-49_swim_clean.csv"
write.csv(dat, file = outfile, quote = FALSE, row.names = FALSE)
----

Expand Down Expand Up @@ -503,7 +503,7 @@ The timestamps now reflect the current time, but the group raises a new concern.
[source,r,cell-code]
----
format(Sys.time(), "%Y-%B-%d_%H-%M-%S")
#> [1] "2024-October-12_07-14-20"
#> [1] "2024-October-13_07-14-50"
----

This formats `+Sys.time()+` in such a way that it includes the month _name_ (not number) and the local timefootnote:[It would clearly be better to format according to ISO 8601, which encodes the month by number, but please humor me for the sake of making this example more obvious.].
Expand Down Expand Up @@ -549,18 +549,18 @@ format(Sys.time(), "%Y-%B-%d_%H-%M-%S")
----

....
#> [1] "2024-outubro-12_04-14-21"
#> [1] "2024-outubro-13_04-14-50"
....

After:

[source,r,cell-code]
----
outfile_path("INFILE.csv")
#> [1] "2024-October-12_07-14-20_INFILE_clean.csv"
#> [1] "2024-October-13_07-14-50_INFILE_clean.csv"
format(Sys.time(), "%Y-%B-%d_%H-%M-%S")
#> [1] "2024-October-12_07-14-21"
#> [1] "2024-October-13_07-14-50"
----

Notice that her month name switched from Portuguese to English and the time is clearly being reported in a different time zone. The calls to `+Sys.setlocale()+` and `+Sys.setenv()+` inside `+timestamp()+` have made persistent (and very surprising) changes to her R session. This sort of side effect is very undesirable and is extremely difficult to track down and debug, especially in more complicated settings.
Expand Down
2 changes: 1 addition & 1 deletion book-asciidoc/preface.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ devtools::session_info()
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
#> date 2024-10-12
#> date 2024-10-13
#> pandoc 2.9.2.1 @ /usr/bin/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────
Expand Down
8 changes: 4 additions & 4 deletions book-asciidoc/website.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ usethis::use_pkgdown()
----

....
#> ✔ Setting active project to "/tmp/RtmpRvHgQG/mypackage".
#> ✔ Setting active project to "/tmp/RtmpHuGXf8/mypackage".
#> ✔ Adding "^_pkgdown\\.yml$", "^docs$", and "^pkgdown$" to
#> '.Rbuildignore'.
#> ✔ Adding "docs" to '.gitignore'.
Expand All @@ -51,7 +51,7 @@ pkgdown::build_site()
----

....
#> ✔ Setting active project to "/tmp/RtmpRvHgQG/mypackage".
#> ✔ Setting active project to "/tmp/RtmpHuGXf8/mypackage".
#> ── Installing package mypackage into temporary library ─────────────
#> ── Initialising site ───────────────────────────────────────────────────────────
#> Copying <pkgdown>/BS5/assets/katex-auto.js to katex-auto.js
Expand Down Expand Up @@ -84,8 +84,8 @@ pkgdown::build_site()
#> Updating deps/search-1.0.0/fuse.min.js
#> Updating deps/search-1.0.0/mark.min.js
#> ── Building pkgdown site for package mypackage ─────────────────────────────────
#> Reading from: /tmp/RtmpRvHgQG/mypackage
#> Writing to: /tmp/RtmpRvHgQG/mypackage/docs
#> Reading from: /tmp/RtmpHuGXf8/mypackage
#> Writing to: /tmp/RtmpHuGXf8/mypackage/docs
#> ── Sitrep ──────────────────────────────────────────────────────────────────────
#> ✖ URLs not ok.
#> In _pkgdown.yml, url is missing.
Expand Down
22 changes: 11 additions & 11 deletions book-asciidoc/whole-game.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ create_package("~/path/to/regexcite")
For the creation of this book we have to work in a temporary directory, because the book is built non-interactively in the cloud. Behind the scenes, we’re executing our own `+create_package()+` command, but don’t be surprised if our output differs a bit from yours.

....
#> ✔ Creating '/tmp/RtmpSEhm0k/regexcite/'.
#> ✔ Setting active project to "/tmp/RtmpSEhm0k/regexcite".
#> ✔ Creating '/tmp/Rtmp58Dgwr/regexcite/'.
#> ✔ Setting active project to "/tmp/Rtmp58Dgwr/regexcite".
#> ✔ Creating 'R/'.
#> ✔ Writing 'DESCRIPTION'.
#> Package: regexcite
Expand Down Expand Up @@ -159,7 +159,7 @@ Click on History (the clock icon in the Git pane) and, if you consented, you wil
[width="100%",cols="<21%,<59%,<20%",options="header",]
|===
|commit |author |message
|f865d7c6ed… |jennybc [email protected] |Initial commit
|12d644e52e… |jennybc [email protected] |Initial commit
|===

[TIP]
Expand Down Expand Up @@ -320,7 +320,7 @@ check()

....
── R CMD check results ─────────────────── regexcite 0.0.0.9000 ────
Duration: 6.6s
Duration: 7.2s
❯ checking DESCRIPTION meta-information ... WARNING
Non-standard license specification:
Expand Down Expand Up @@ -496,7 +496,7 @@ check()

....
── R CMD check results ─────────────────── regexcite 0.0.0.9000 ────
Duration: 8.2s
Duration: 8.8s
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
....
Expand All @@ -512,14 +512,14 @@ install()

....
── R CMD build ─────────────────────────────────────────────────────
* checking for file ‘/tmp/RtmpSEhm0k/regexcite/DESCRIPTION’ ... OK
* checking for file ‘/tmp/Rtmp58Dgwr/regexcite/DESCRIPTION’ ... OK
* preparing ‘regexcite’:
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* building ‘regexcite_0.0.0.9000.tar.gz’
Running /opt/R/4.4.1/lib/R/bin/R CMD INSTALL \
/tmp/RtmpSEhm0k/regexcite_0.0.0.9000.tar.gz --install-tests
/tmp/Rtmp58Dgwr/regexcite_0.0.0.9000.tar.gz --install-tests
* installing to library ‘/home/runner/work/_temp/Library’
* installing *source* package ‘regexcite’ ...
** using staged installation
Expand Down Expand Up @@ -874,7 +874,7 @@ The very best way to render `+README.Rmd+` is with `+build_readme()+`, because i
----
build_readme()
#> ℹ Installing regexcite in temporary library
#> ℹ Building '/tmp/RtmpSEhm0k/regexcite/README.Rmd'
#> ℹ Building '/tmp/Rtmp58Dgwr/regexcite/README.Rmd'
----

You can see the rendered `+README.md+` simply by https://github.com/jennybc/regexcite#readme[visiting regexcite on GitHub].
Expand All @@ -892,7 +892,7 @@ check()

....
── R CMD check results ─────────────────── regexcite 0.0.0.9000 ────
Duration: 9.5s
Duration: 9.8s
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
....
Expand All @@ -906,15 +906,15 @@ install()

....
── R CMD build ─────────────────────────────────────────────────────
* checking for file ‘/tmp/RtmpSEhm0k/regexcite/DESCRIPTION’ ... OK
* checking for file ‘/tmp/Rtmp58Dgwr/regexcite/DESCRIPTION’ ... OK
* preparing ‘regexcite’:
* checking DESCRIPTION meta-information ... OK
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
Removed empty directory ‘regexcite/tests/testthat/_snaps’
* building ‘regexcite_0.0.0.9000.tar.gz’
Running /opt/R/4.4.1/lib/R/bin/R CMD INSTALL \
/tmp/RtmpSEhm0k/regexcite_0.0.0.9000.tar.gz --install-tests
/tmp/Rtmp58Dgwr/regexcite_0.0.0.9000.tar.gz --install-tests
* installing to library ‘/home/runner/work/_temp/Library’
* installing *source* package ‘regexcite’ ...
** using staged installation
Expand Down
2 changes: 1 addition & 1 deletion dependencies-mindset-background.html
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ <h1 class="title"><span id="sec-dependencies-mindset-background" class="quarto-s
<span><span class="co">#&gt; function (x, na.rm = FALSE) </span></span>
<span><span class="co">#&gt; sqrt(var(if (is.vector(x) || is.factor(x)) x else as.double(x), </span></span>
<span><span class="co">#&gt; na.rm = na.rm))</span></span>
<span><span class="co">#&gt; &lt;bytecode: 0x5584ced97e20&gt;</span></span>
<span><span class="co">#&gt; &lt;bytecode: 0x56376796bb68&gt;</span></span>
<span><span class="co">#&gt; &lt;environment: namespace:stats&gt;</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>It’s defined in terms of another function, <code><a href="https://rdrr.io/r/stats/cor.html">var()</a></code>, also from the stats package. So what happens if we override <code><a href="https://rdrr.io/r/stats/cor.html">var()</a></code> with our own definition? Does it break <code><a href="https://rdrr.io/r/stats/sd.html">sd()</a></code>?</p>
Expand Down
10 changes: 5 additions & 5 deletions package-within.html
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ <h1 class="title"><span id="sec-package-within" class="quarto-section-identifier
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="va">now</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/Sys.time.html">Sys.time</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="va">timestamp</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/format.html">format</a></span><span class="op">(</span><span class="va">now</span>, <span class="st">"%Y-%B-%d_%H-%M-%S"</span><span class="op">)</span></span>
<span><span class="op">(</span><span class="va">outfile</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste0</a></span><span class="op">(</span><span class="va">timestamp</span>, <span class="st">"_"</span>, <span class="fu"><a href="https://rdrr.io/r/base/grep.html">sub</a></span><span class="op">(</span><span class="st">"(.*)([.]csv$)"</span>, <span class="st">"\\1_clean\\2"</span>, <span class="va">infile</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></span>
<span><span class="co">#&gt; [1] "2024-October-12_07-14-17_swim_clean.csv"</span></span>
<span><span class="co">#&gt; [1] "2024-October-13_07-14-46_swim_clean.csv"</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/utils/write.table.html">write.csv</a></span><span class="op">(</span><span class="va">dat</span>, file <span class="op">=</span> <span class="va">outfile</span>, quote <span class="op">=</span> <span class="cn">FALSE</span>, row.names <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Here is <code>data-cleaning.R</code> in its entirety:</p>
Expand Down Expand Up @@ -828,7 +828,7 @@ <h1 class="title"><span id="sec-package-within" class="quarto-section-identifier
<p>The timestamps now reflect the current time, but the group raises a new concern. As it stands, the timestamps reflect who has done the data cleaning and which part of the world they’re in. The heart of the timestamp strategy is this format string<a href="#fn5" class="footnote-ref" id="fnref5" role="doc-noteref"><sup>5</sup></a>:</p>
<div class="cell">
<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/format.html">format</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/Sys.time.html">Sys.time</a></span><span class="op">(</span><span class="op">)</span>, <span class="st">"%Y-%B-%d_%H-%M-%S"</span><span class="op">)</span></span>
<span><span class="co">#&gt; [1] "2024-October-12_07-14-17"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<span><span class="co">#&gt; [1] "2024-October-13_07-14-46"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>This formats <code><a href="https://rdrr.io/r/base/Sys.time.html">Sys.time()</a></code> in such a way that it includes the month <em>name</em> (not number) and the local time<a href="#fn6" class="footnote-ref" id="fnref6" role="doc-noteref"><sup>6</sup></a>.</p>
<p><a href="#tbl-timestamps" class="quarto-xref">Table&nbsp;<span>5.1</span></a> shows what happens when such a timestamp is produced by several hypothetical colleagues cleaning some data at exactly the same instant in time.</p>
Expand Down Expand Up @@ -904,15 +904,15 @@ <h1 class="title"><span id="sec-package-within" class="quarto-section-identifier
<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/format.html">format</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/Sys.time.html">Sys.time</a></span><span class="op">(</span><span class="op">)</span>, <span class="st">"%Y-%B-%d_%H-%M-%S"</span><span class="op">)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell">
<pre><code>#&gt; [1] "2024-outubro-12_04-14-17"</code></pre>
<pre><code>#&gt; [1] "2024-outubro-13_04-14-47"</code></pre>
</div>
<p>After:</p>
<div class="cell">
<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu">outfile_path</span><span class="op">(</span><span class="st">"INFILE.csv"</span><span class="op">)</span></span>
<span><span class="co">#&gt; [1] "2024-October-12_07-14-17_INFILE_clean.csv"</span></span>
<span><span class="co">#&gt; [1] "2024-October-13_07-14-46_INFILE_clean.csv"</span></span>
<span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/format.html">format</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/Sys.time.html">Sys.time</a></span><span class="op">(</span><span class="op">)</span>, <span class="st">"%Y-%B-%d_%H-%M-%S"</span><span class="op">)</span></span>
<span><span class="co">#&gt; [1] "2024-October-12_07-14-17"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<span><span class="co">#&gt; [1] "2024-October-13_07-14-47"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Notice that her month name switched from Portuguese to English and the time is clearly being reported in a different time zone. The calls to <code><a href="https://rdrr.io/r/base/locales.html">Sys.setlocale()</a></code> and <code><a href="https://rdrr.io/r/base/Sys.setenv.html">Sys.setenv()</a></code> inside <code><a href="https://rdrr.io/r/utils/savehistory.html">timestamp()</a></code> have made persistent (and very surprising) changes to her R session. This sort of side effect is very undesirable and is extremely difficult to track down and debug, especially in more complicated settings.</p>
<p>Here are better versions of <code><a href="https://rdrr.io/r/utils/savehistory.html">timestamp()</a></code>:</p>
Expand Down
2 changes: 1 addition & 1 deletion preface.html
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ <h1 class="title"><span id="sec-preface" class="quarto-section-identifier">Prefa
<span><span class="co">#&gt; collate C.UTF-8</span></span>
<span><span class="co">#&gt; ctype C.UTF-8</span></span>
<span><span class="co">#&gt; tz UTC</span></span>
<span><span class="co">#&gt; date 2024-10-12</span></span>
<span><span class="co">#&gt; date 2024-10-13</span></span>
<span><span class="co">#&gt; pandoc 2.9.2.1 @ /usr/bin/ (via rmarkdown)</span></span>
<span><span class="co">#&gt; </span></span>
<span><span class="co">#&gt; ─ Packages ───────────────────────────────────────────────────────</span></span>
Expand Down
Loading

0 comments on commit 26008f6

Please sign in to comment.