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 15, 2025
1 parent 6bfc430 commit d4754d2
Show file tree
Hide file tree
Showing 16 changed files with 262 additions and 262 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: 0x55b712e64258>
#> <bytecode: 0x556212e955b8>
#> <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-14_07-15-07_swim_clean.csv"
#> [1] "2025-January-15_07-15-07_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-14_07-15-07"
#> [1] "2025-January-15_07-15-07"
----

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

After:

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

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
138 changes: 69 additions & 69 deletions book-asciidoc/preface.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -113,78 +113,78 @@ devtools::session_info()
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
#> date 2025-01-14
#> date 2025-01-15
#> pandoc 3.1.3 @ /usr/bin/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> bit 4.5.0.1 2024-12-03 [1] RSPM
#> bit64 4.5.2 2024-09-22 [1] RSPM
#> brio 1.1.5 2024-04-24 [1] RSPM
#> cachem 1.1.0 2024-05-16 [1] RSPM
#> cli 3.6.3 2024-06-21 [1] RSPM
#> colorspace 2.1-1 2024-07-26 [1] RSPM
#> crayon 1.5.3 2024-06-20 [1] RSPM
#> devtools * 2.4.5 2022-10-11 [1] RSPM
#> digest 0.6.37 2024-08-19 [1] RSPM
#> dplyr * 1.1.4 2023-11-17 [1] RSPM
#> ellipsis 0.3.2 2021-04-29 [1] RSPM
#> evaluate 1.0.3 2025-01-10 [1] RSPM
#> fastmap 1.2.0 2024-05-15 [1] RSPM
#> forcats * 1.0.0 2023-01-29 [1] RSPM
#> fs 1.6.5 2024-10-30 [1] RSPM
#> generics 0.1.3 2022-07-05 [1] RSPM
#> ggplot2 * 3.5.1 2024-04-23 [1] RSPM
#> glue 1.8.0 2024-09-30 [1] RSPM
#> gtable 0.3.6 2024-10-25 [1] RSPM
#> hms 1.1.3 2023-03-21 [1] RSPM
#> htmltools 0.5.8.1 2024-04-04 [1] RSPM
#> htmlwidgets 1.6.4 2023-12-06 [1] RSPM
#> httpuv 1.6.15 2024-03-26 [1] RSPM
#> jsonlite 1.8.9 2024-09-20 [1] RSPM
#> knitr 1.49 2024-11-08 [1] RSPM
#> later 1.4.1 2024-11-27 [1] RSPM
#> lifecycle 1.0.4 2023-11-07 [1] RSPM
#> lubridate * 1.9.4 2024-12-08 [1] RSPM
#> magrittr 2.0.3 2022-03-30 [1] RSPM
#> memoise 2.0.1 2021-11-26 [1] RSPM
#> 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.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
#> profvis 0.4.0 2024-09-20 [1] RSPM
#> promises 1.3.2 2024-11-28 [1] RSPM
#> purrr * 1.0.2 2023-08-10 [1] RSPM
#> R6 2.5.1 2021-08-19 [1] RSPM
#> Rcpp 1.0.13-1 2024-11-02 [1] RSPM
#> readr * 2.1.5 2024-01-10 [1] RSPM
#> remotes 2.5.0 2024-03-17 [1] RSPM
#> rlang 1.1.4 2024-06-04 [1] RSPM
#> rmarkdown 2.29 2024-11-04 [1] RSPM
#> roxygen2 * 7.3.2 2024-06-28 [1] RSPM
#> scales 1.3.0 2023-11-28 [1] RSPM
#> sessioninfo 1.2.2 2021-12-06 [1] RSPM
#> shiny 1.10.0 2024-12-14 [1] RSPM
#> stringi 1.8.4 2024-05-06 [1] RSPM
#> stringr * 1.5.1 2023-11-14 [1] RSPM
#> testthat * 3.2.2 2024-12-10 [1] RSPM
#> tibble * 3.2.1 2023-03-20 [1] RSPM
#> tidyr * 1.3.1 2024-01-24 [1] RSPM
#> tidyselect 1.2.1 2024-03-11 [1] RSPM
#> tidyverse * 2.0.0 2023-02-22 [1] RSPM
#> timechange 0.3.0 2024-01-18 [1] RSPM
#> tzdb 0.4.0 2023-05-12 [1] RSPM
#> urlchecker 1.0.1 2021-11-30 [1] RSPM
#> usethis * 3.1.0 2024-11-26 [1] RSPM
#> 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.50 2025-01-07 [1] RSPM
#> xml2 1.3.6 2023-12-04 [1] RSPM
#> xtable 1.8-4 2019-04-21 [1] RSPM
#> package * version date (UTC) lib source
#> bit 4.5.0.1 2024-12-03 [1] RSPM
#> bit64 4.5.2 2024-09-22 [1] RSPM
#> brio 1.1.5 2024-04-24 [1] RSPM
#> cachem 1.1.0 2024-05-16 [1] RSPM
#> cli 3.6.3 2024-06-21 [1] RSPM
#> colorspace 2.1-1 2024-07-26 [1] RSPM
#> crayon 1.5.3 2024-06-20 [1] RSPM
#> devtools * 2.4.5 2022-10-11 [1] RSPM
#> digest 0.6.37 2024-08-19 [1] RSPM
#> dplyr * 1.1.4 2023-11-17 [1] RSPM
#> ellipsis 0.3.2 2021-04-29 [1] RSPM
#> evaluate 1.0.3 2025-01-10 [1] RSPM
#> fastmap 1.2.0 2024-05-15 [1] RSPM
#> forcats * 1.0.0 2023-01-29 [1] RSPM
#> fs 1.6.5 2024-10-30 [1] RSPM
#> generics 0.1.3 2022-07-05 [1] RSPM
#> ggplot2 * 3.5.1 2024-04-23 [1] RSPM
#> glue 1.8.0 2024-09-30 [1] RSPM
#> gtable 0.3.6 2024-10-25 [1] RSPM
#> hms 1.1.3 2023-03-21 [1] RSPM
#> htmltools 0.5.8.1 2024-04-04 [1] RSPM
#> htmlwidgets 1.6.4 2023-12-06 [1] RSPM
#> httpuv 1.6.15 2024-03-26 [1] RSPM
#> jsonlite 1.8.9 2024-09-20 [1] RSPM
#> knitr 1.49 2024-11-08 [1] RSPM
#> later 1.4.1 2024-11-27 [1] RSPM
#> lifecycle 1.0.4 2023-11-07 [1] RSPM
#> lubridate * 1.9.4 2024-12-08 [1] RSPM
#> magrittr 2.0.3 2022-03-30 [1] RSPM
#> memoise 2.0.1 2021-11-26 [1] RSPM
#> 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.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
#> profvis 0.4.0 2024-09-20 [1] RSPM
#> promises 1.3.2 2024-11-28 [1] RSPM
#> purrr * 1.0.2 2023-08-10 [1] RSPM
#> R6 2.5.1 2021-08-19 [1] RSPM
#> Rcpp 1.0.14 2025-01-12 [1] RSPM
#> readr * 2.1.5 2024-01-10 [1] RSPM
#> remotes 2.5.0 2024-03-17 [1] RSPM
#> rlang 1.1.4 2024-06-04 [1] RSPM
#> rmarkdown 2.29 2024-11-04 [1] RSPM
#> roxygen2 * 7.3.2 2024-06-28 [1] RSPM
#> scales 1.3.0 2023-11-28 [1] RSPM
#> sessioninfo 1.2.2 2021-12-06 [1] RSPM
#> shiny 1.10.0 2024-12-14 [1] RSPM
#> stringi 1.8.4 2024-05-06 [1] RSPM
#> stringr * 1.5.1 2023-11-14 [1] RSPM
#> testthat * 3.2.3 2025-01-13 [1] RSPM
#> tibble * 3.2.1 2023-03-20 [1] RSPM
#> tidyr * 1.3.1 2024-01-24 [1] RSPM
#> tidyselect 1.2.1 2024-03-11 [1] RSPM
#> tidyverse * 2.0.0 2023-02-22 [1] RSPM
#> timechange 0.3.0 2024-01-18 [1] RSPM
#> tzdb 0.4.0 2023-05-12 [1] RSPM
#> urlchecker 1.0.1 2021-11-30 [1] RSPM
#> usethis * 3.1.0 2024-11-26 [1] RSPM
#> 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.50 2025-01-07 [1] RSPM
#> xml2 1.3.6 2023-12-04 [1] RSPM
#> xtable 1.8-4 2019-04-21 [1] RSPM
#>
#> [1] /home/runner/work/_temp/Library
#> [2] /opt/R/4.4.2/lib/R/site-library
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 @@ -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 @@ -324,13 +324,13 @@ test_that("multiplication works", {
useful_thing <- 3
expect_equal(2 * useful_thing, 6)
})
#> Test passed 🎊
#> Test passed 🥇
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/RtmpHhaYZi/mypackage".
#> ✔ Setting active project to "/tmp/RtmpmjDQO8/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/RtmpHhaYZi/mypackage".
#> ✔ Setting active project to "/tmp/RtmpmjDQO8/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/RtmpHhaYZi/mypackage
#> Writing to: /tmp/RtmpHhaYZi/mypackage/docs
#> Reading from: /tmp/RtmpmjDQO8/mypackage
#> Writing to: /tmp/RtmpmjDQO8/mypackage/docs
#> ── Sitrep ──────────────────────────────────────────────────────────────────────
#> ✖ URLs not ok.
#> In _pkgdown.yml, url is missing.
Expand Down
20 changes: 10 additions & 10 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/RtmpYNCahH/regexcite/'.
#> ✔ Setting active project to "/tmp/RtmpYNCahH/regexcite".
#> ✔ Creating '/tmp/RtmpqMz1Vr/regexcite/'.
#> ✔ Setting active project to "/tmp/RtmpqMz1Vr/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
|edd360a607… |jennybc [email protected] |Initial commit
|891f1d98ad… |jennybc [email protected] |Initial commit
|===

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

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

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

....
── R CMD build ─────────────────────────────────────────────────────
* checking for file ‘/tmp/RtmpYNCahH/regexcite/DESCRIPTION’ ... OK
* checking for file ‘/tmp/RtmpqMz1Vr/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/RtmpYNCahH/regexcite_0.0.0.9000.tar.gz --install-tests
/tmp/RtmpqMz1Vr/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: 0x55f845c67218&gt;</span></span>
<span><span class="co">#&gt; &lt;bytecode: 0x5562b5fd2ed0&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 d4754d2

Please sign in to comment.