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 Jan 9, 2025
1 parent 01dfa82 commit ccde263
Show file tree
Hide file tree
Showing 20 changed files with 144 additions and 144 deletions.
2 changes: 1 addition & 1 deletion book-asciidoc/data.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ If the `+DESCRIPTION+` contains `+LazyData: true+`, then datasets will be lazily
[source,r,cell-code]
----
lobstr::mem_used()
#> 57.94 MB
#> 57.95 MB
library(nycflights13)
lobstr::mem_used()
#> 59.70 MB
Expand Down
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: 0x55cea41c8178>
#> <bytecode: 0x55b887186fb0>
#> <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] "2025-January-08_07-15-06_swim_clean.csv"
#> [1] "2025-January-09_07-15-32_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] "2025-January-08_07-15-07"
#> [1] "2025-January-09_07-15-32"
----

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] "2025-janeiro-08_04-15-07"
#> [1] "2025-janeiro-09_04-15-33"
....

After:

[source,r,cell-code]
----
outfile_path("INFILE.csv")
#> [1] "2025-January-08_07-15-07_INFILE_clean.csv"
#> [1] "2025-January-09_07-15-32_INFILE_clean.csv"
format(Sys.time(), "%Y-%B-%d_%H-%M-%S")
#> [1] "2025-January-08_07-15-07"
#> [1] "2025-January-09_07-15-33"
----

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
6 changes: 3 additions & 3 deletions 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 2025-01-08
#> date 2025-01-09
#> pandoc 2.9.2.1 @ /usr/bin/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────
Expand Down Expand Up @@ -151,7 +151,7 @@ devtools::session_info()
#> mime 0.12 2021-09-28 [1] RSPM
#> miniUI 0.1.1.1 2018-05-18 [1] RSPM
#> munsell 0.5.1 2024-04-01 [1] RSPM
#> pillar 1.10.0 2024-12-17 [1] RSPM
#> pillar 1.10.1 2025-01-07 [1] RSPM
#> pkgbuild 1.4.5 2024-10-28 [1] RSPM
#> pkgconfig 2.0.3 2019-09-22 [1] RSPM
#> pkgload 1.4.0 2024-06-28 [1] RSPM
Expand Down Expand Up @@ -182,7 +182,7 @@ devtools::session_info()
#> vctrs 0.6.5 2023-12-01 [1] RSPM
#> vroom 1.6.5 2023-12-05 [1] RSPM
#> withr 3.0.2 2024-10-28 [1] RSPM
#> xfun 0.49 2024-10-31 [1] RSPM
#> xfun 0.50 2025-01-07 [1] RSPM
#> xml2 1.3.6 2023-12-04 [1] RSPM
#> xtable 1.8-4 2019-04-21 [1] RSPM
#>
Expand Down
6 changes: 3 additions & 3 deletions book-asciidoc/testing-basics.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -265,18 +265,18 @@ test_that("basic duplication works", {
expect_equal(str_dup(c("a", "b"), 2), c("aa", "bb"))
expect_equal(str_dup(c("a", "b"), c(2, 3)), c("aa", "bbb"))
})
#> Test passed 😸
#> Test passed 🎊
test_that("0 duplicates equals empty string", {
expect_equal(str_dup("a", 0), "")
expect_equal(str_dup(c("a", "b"), 0), rep("", 2))
})
#> Test passed 😸
#> Test passed 🎉
test_that("uses tidyverse recycling rules", {
expect_error(str_dup(1:2, 1:3), class = "vctrs_error_incompatible_size")
})
#> Test passed 🥇
#> Test passed 🎊
----

This file shows a typical mix of tests:
Expand Down
10 changes: 5 additions & 5 deletions book-asciidoc/testing-design.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ test_that("landscape changes leak outside the test", {
expect_equal(getOption("opt_whatever"), "whatever")
expect_equal(Sys.getenv("envvar_whatever"), "whatever")
})
#> Test passed 🌈
#> Test passed 🥳
grep("jsonlite", search(), value = TRUE)
#> [1] "package:jsonlite"
Expand Down Expand Up @@ -233,7 +233,7 @@ test_that("withr makes landscape changes local to a test", {
expect_equal(getOption("opt_whatever"), "whatever")
expect_equal(Sys.getenv("envvar_whatever"), "whatever")
})
#> Test passed 😸
#> Test passed 😀
grep("jsonlite", search(), value = TRUE)
#> character(0)
Expand Down Expand Up @@ -330,7 +330,7 @@ test_that("subtraction works", {
useful_thing <- 3
expect_equal(5 - useful_thing, 2)
})
#> Test passed 🎊
#> Test passed 🌈
----

In real life, `+useful_thing+` is usually a more complicated object that somehow feels burdensome to instantiate. Notice how `+useful_thing <- 3+` appears in more than one place. Conventional wisdom says we should DRY this code out. It’s tempting to just move `+useful_thing+`’s definition outside of the tests:
Expand All @@ -342,12 +342,12 @@ useful_thing <- 3
test_that("multiplication works", {
expect_equal(2 * useful_thing, 6)
})
#> Test passed 🥳
#> Test passed 😀
test_that("subtraction works", {
expect_equal(5 - useful_thing, 2)
})
#> Test passed 🥇
#> Test passed 😸
----

But we really do think the first form, with the repetition, is often the better choice.
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/RtmpQ8Xj2M/mypackage".
#> ✔ Setting active project to "/tmp/RtmpJEIQm9/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/RtmpQ8Xj2M/mypackage".
#> ✔ Setting active project to "/tmp/RtmpJEIQm9/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/RtmpQ8Xj2M/mypackage
#> Writing to: /tmp/RtmpQ8Xj2M/mypackage/docs
#> Reading from: /tmp/RtmpJEIQm9/mypackage
#> Writing to: /tmp/RtmpJEIQm9/mypackage/docs
#> ── Sitrep ──────────────────────────────────────────────────────────────────────
#> ✖ URLs not ok.
#> In _pkgdown.yml, url is missing.
Expand Down
18 changes: 9 additions & 9 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/RtmpvS3Toa/regexcite/'.
#> ✔ Setting active project to "/tmp/RtmpvS3Toa/regexcite".
#> ✔ Creating '/tmp/RtmpwIwJgQ/regexcite/'.
#> ✔ Setting active project to "/tmp/RtmpwIwJgQ/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
|c2ae46871b… |jennybc [email protected] |Initial commit
|2e021ee080… |jennybc [email protected] |Initial commit
|===

[TIP]
Expand Down Expand Up @@ -512,14 +512,14 @@ install()

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

....
── R CMD build ─────────────────────────────────────────────────────
* checking for file ‘/tmp/RtmpvS3Toa/regexcite/DESCRIPTION’ ... OK
* checking for file ‘/tmp/RtmpwIwJgQ/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/RtmpvS3Toa/regexcite_0.0.0.9000.tar.gz --install-tests
/tmp/RtmpwIwJgQ/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
4 changes: 2 additions & 2 deletions data.html
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,14 @@ <h1 class="title"><span id="sec-data" class="quarto-section-identifier"><span cl
<p>If the <code>DESCRIPTION</code> contains <code>LazyData: true</code>, then datasets will be lazily loaded. This means that they won’t occupy any memory until you use them. The following example shows memory usage before and after loading the nycflights13 package. You can see that memory usage doesn’t change significantly until you inspect the <code>flights</code> dataset stored inside the package.</p>
<div class="cell">
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r code-with-copy"><code class="sourceCode R"><span><span class="fu">lobstr</span><span class="fu">::</span><span class="fu"><a href="https://lobstr.r-lib.org/reference/mem_used.html">mem_used</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="co">#&gt; 58.00 MB</span></span>
<span><span class="co">#&gt; 58.01 MB</span></span>
<span><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/hadley/nycflights13">nycflights13</a></span><span class="op">)</span></span>
<span><span class="fu">lobstr</span><span class="fu">::</span><span class="fu"><a href="https://lobstr.r-lib.org/reference/mem_used.html">mem_used</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="co">#&gt; 59.76 MB</span></span>
<span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/invisible.html">invisible</a></span><span class="op">(</span><span class="va">flights</span><span class="op">)</span></span>
<span><span class="fu">lobstr</span><span class="fu">::</span><span class="fu"><a href="https://lobstr.r-lib.org/reference/mem_used.html">mem_used</a></span><span class="op">(</span><span class="op">)</span></span>
<span><span class="co">#&gt; 100.46 MB</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<span><span class="co">#&gt; 100.47 MB</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>We recommend that you include <code>LazyData: true</code> in your <code>DESCRIPTION</code> if you are shipping <code>.rda</code> files below <code>data/</code>. If you use <code>use_data()</code> to create such datasets, it will automatically make this modification to <code>DESCRIPTION</code> for you.</p>
<div class="callout callout-style-default callout-warning callout-titled">
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: 0x558948ac2008&gt;</span></span>
<span><span class="co">#&gt; &lt;bytecode: 0x55dbe8609da0&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
Loading

0 comments on commit ccde263

Please sign in to comment.