Skip to content

Commit

Permalink
Deploying to gh-pages from @ d6e3d3f 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Dec 3, 2024
1 parent 3696156 commit 0466d7a
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 112 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: 0x55aedf1268d8>
#> <bytecode: 0x558fb8932848>
#> <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-December-02_07-15-36_swim_clean.csv"
#> [1] "2024-December-03_07-14-47_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-December-02_07-15-36"
#> [1] "2024-December-03_07-14-47"
----

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-dezembro-02_04-15-37"
#> [1] "2024-dezembro-03_04-14-48"
....

After:

[source,r,cell-code]
----
outfile_path("INFILE.csv")
#> [1] "2024-December-02_07-15-36_INFILE_clean.csv"
#> [1] "2024-December-03_07-14-47_INFILE_clean.csv"
format(Sys.time(), "%Y-%B-%d_%H-%M-%S")
#> [1] "2024-December-02_07-15-37"
#> [1] "2024-December-03_07-14-48"
----

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-12-02
#> date 2024-12-03
#> 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/RtmpLfKNsJ/mypackage".
#> ✔ Setting active project to "/tmp/RtmppFdt1G/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/RtmpLfKNsJ/mypackage".
#> ✔ Setting active project to "/tmp/RtmppFdt1G/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/RtmpLfKNsJ/mypackage
#> Writing to: /tmp/RtmpLfKNsJ/mypackage/docs
#> Reading from: /tmp/RtmppFdt1G/mypackage
#> Writing to: /tmp/RtmppFdt1G/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/Rtmp6hvVd9/regexcite/'.
#> ✔ Setting active project to "/tmp/Rtmp6hvVd9/regexcite".
#> ✔ Creating '/tmp/Rtmp6NS7qI/regexcite/'.
#> ✔ Setting active project to "/tmp/Rtmp6NS7qI/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
|01f5c1b8e7… |jennybc [email protected] |Initial commit
|e6eae0860b… |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: 7.6s
Duration: 6.8s
❯ 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: 9.2s
Duration: 8.2s
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
....
Expand All @@ -512,14 +512,14 @@ install()

....
── R CMD build ─────────────────────────────────────────────────────
* checking for file ‘/tmp/Rtmp6hvVd9/regexcite/DESCRIPTION’ ... OK
* checking for file ‘/tmp/Rtmp6NS7qI/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.2/lib/R/bin/R CMD INSTALL \
/tmp/Rtmp6hvVd9/regexcite_0.0.0.9000.tar.gz --install-tests
/tmp/Rtmp6NS7qI/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/Rtmp6hvVd9/regexcite/README.Rmd'
#> ℹ Building '/tmp/Rtmp6NS7qI/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: 10.2s
Duration: 9.4s
0 errors ✔ | 0 warnings ✔ | 0 notes ✔
....
Expand All @@ -906,15 +906,15 @@ install()

....
── R CMD build ─────────────────────────────────────────────────────
* checking for file ‘/tmp/Rtmp6hvVd9/regexcite/DESCRIPTION’ ... OK
* checking for file ‘/tmp/Rtmp6NS7qI/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.2/lib/R/bin/R CMD INSTALL \
/tmp/Rtmp6hvVd9/regexcite_0.0.0.9000.tar.gz --install-tests
/tmp/Rtmp6NS7qI/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: 0x559c40d55388&gt;</span></span>
<span><span class="co">#&gt; &lt;bytecode: 0x558dd77ca388&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-December-02_07-15-33_swim_clean.csv"</span></span>
<span><span class="co">#&gt; [1] "2024-December-03_07-14-44_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-December-02_07-15-33"</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-December-03_07-14-44"</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-dezembro-02_04-15-34"</code></pre>
<pre><code>#&gt; [1] "2024-dezembro-03_04-14-45"</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-December-02_07-15-33_INFILE_clean.csv"</span></span>
<span><span class="co">#&gt; [1] "2024-December-03_07-14-44_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-December-02_07-15-34"</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-December-03_07-14-45"</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-12-02</span></span>
<span><span class="co">#&gt; date 2024-12-03</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 0466d7a

Please sign in to comment.