diff --git a/Conditions.md b/Conditions.md
index a044bdef..4eee9297 100644
--- a/Conditions.md
+++ b/Conditions.md
@@ -301,7 +301,7 @@ rlang::catch_cnd
#> return(NULL)
#> })))
#> }
-#>
+#>
#>
```
@@ -718,8 +718,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -732,7 +732,7 @@ sessioninfo::session_info(include_base = TRUE)
#> compiler 4.4.1 2024-06-14 [3] local
#> datasets * 4.4.1 2024-06-14 [3] local
#> desc 1.4.3 2023-12-10 [1] RSPM
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> dplyr 1.1.4 2023-11-17 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
@@ -753,7 +753,7 @@ sessioninfo::session_info(include_base = TRUE)
#> methods * 4.4.1 2024-06-14 [3] local
#> pillar 1.9.0 2023-03-22 [1] RSPM
#> pkgconfig 2.0.3 2019-09-22 [1] RSPM
-#> pkgload 1.3.4 2024-01-16 [1] RSPM
+#> pkgload 1.4.0 2024-06-28 [1] RSPM
#> R6 2.5.1 2021-08-19 [1] RSPM
#> rlang * 1.1.4 2024-06-04 [1] RSPM
#> rmarkdown 2.27 2024-05-17 [1] RSPM
diff --git a/Control-flow.md b/Control-flow.md
index 360e0ccf..0d83eae3 100644
--- a/Control-flow.md
+++ b/Control-flow.md
@@ -276,8 +276,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -288,7 +288,7 @@ sessioninfo::session_info(include_base = TRUE)
#> cli 3.6.3 2024-06-21 [1] RSPM
#> compiler 4.4.1 2024-06-14 [3] local
#> datasets * 4.4.1 2024-06-14 [3] local
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
#> fastmap 1.2.0 2024-05-15 [1] RSPM
diff --git a/Environments.md b/Environments.md
index 20667524..6e02f59c 100644
--- a/Environments.md
+++ b/Environments.md
@@ -40,7 +40,7 @@ library(rlang)
e <- env()
e$loop <- e
env_print(e)
-#>
+#>
#> Parent:
#> Bindings:
#> • loop:
@@ -51,8 +51,8 @@ The binding `loop` should have the same memory address as the environment `e`:
``` r
lobstr::ref(e$loop)
-#> █ [1:0x557bf7fd1ff0]
-#> └─loop = [1:0x557bf7fd1ff0]
+#> █ [1:0x55b30b93a7c0]
+#> └─loop = [1:0x55b30b93a7c0]
```
**Q3.** Create a pair of environments as illustrated by this picture.
@@ -71,12 +71,12 @@ e2$deloop <- e1
# following should be the same
lobstr::obj_addrs(list(e1, e2$deloop))
-#> [1] "0x557bf83ad810" "0x557bf83ad810"
+#> [1] "0x55b30c8d1370" "0x55b30c8d1370"
```
``` r
lobstr::obj_addrs(list(e2, e1$loop))
-#> [1] "0x557bf822b778" "0x557bf822b778"
+#> [1] "0x55b30c85b5c0" "0x55b30c85b5c0"
```
**Q4.** Explain why `e[[1]]` and `e[c("a", "b")]` don't make sense when `e` is an environment.
@@ -339,7 +339,7 @@ fget("mean", inherits = FALSE)
fget("mean", inherits = TRUE)
#> function (x, ...)
#> UseMethod("mean")
-#>
+#>
#>
```
@@ -569,7 +569,7 @@ rlang::caller_env
#> {
#> parent.frame(n + 1)
#> }
-#>
+#>
#>
```
@@ -625,8 +625,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -638,7 +638,7 @@ sessioninfo::session_info(include_base = TRUE)
#> compiler 4.4.1 2024-06-14 [3] local
#> crayon 1.5.3 2024-06-20 [1] RSPM
#> datasets * 4.4.1 2024-06-14 [3] local
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> dplyr 1.1.4 2023-11-17 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
diff --git a/Evaluation.md b/Evaluation.md
index 3bb46003..19d74ced 100644
--- a/Evaluation.md
+++ b/Evaluation.md
@@ -49,7 +49,7 @@ withr::with_tempdir(
foo()
}
)
-#>
+#>
#> Parent:
```
@@ -268,7 +268,7 @@ q1 <- new_quosure(expr(x), env(x = 1))
q1
#>
#> expr: ^x
-#> env: 0x564b8c609f48
+#> env: 0x55bdc0255228
```
``` r
@@ -276,7 +276,7 @@ q2 <- new_quosure(expr(x + !!q1), env(x = 10))
q2
#>
#> expr: ^x + (^x)
-#> env: 0x564b8ccf2150
+#> env: 0x55bdbe8f0410
```
``` r
@@ -284,7 +284,7 @@ q3 <- new_quosure(expr(x + !!q2), env(x = 100))
q3
#>
#> expr: ^x + (^x + (^x))
-#> env: 0x564b8da4fc70
+#> env: 0x55bdbce0d408
```
**A1.** Correctly predicted 😉
@@ -331,7 +331,7 @@ enenv(x)
foo <- function(x) enenv(x)
foo()
-#>
+#>
```
---
@@ -722,8 +722,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -734,7 +734,7 @@ sessioninfo::session_info(include_base = TRUE)
#> cli 3.6.3 2024-06-21 [1] RSPM
#> compiler 4.4.1 2024-06-14 [3] local
#> datasets * 4.4.1 2024-06-14 [3] local
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
#> fansi 1.0.6 2023-12-08 [1] RSPM
diff --git a/Expressions.md b/Expressions.md
index da1426ca..b866bfae 100644
--- a/Expressions.md
+++ b/Expressions.md
@@ -437,7 +437,7 @@ call_standardise(quote(mean(x = 1:10, , TRUE)))
mean
#> function (x, ...)
#> UseMethod("mean")
-#>
+#>
#>
```
@@ -1137,8 +1137,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -1150,7 +1150,7 @@ sessioninfo::session_info(include_base = TRUE)
#> compiler 4.4.1 2024-06-14 [3] local
#> crayon 1.5.3 2024-06-20 [1] RSPM
#> datasets * 4.4.1 2024-06-14 [3] local
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
#> fansi 1.0.6 2023-12-08 [1] RSPM
diff --git a/Function-factories.md b/Function-factories.md
index 21f00e64..c36253dc 100644
--- a/Function-factories.md
+++ b/Function-factories.md
@@ -21,7 +21,7 @@ library(ggplot2, warn.conflicts = FALSE)
force
#> function (x)
#> x
-#>
+#>
#>
```
@@ -47,8 +47,8 @@ f <- approxfun(x, y)
f
#> function (v)
#> .approxfun(x, y, v, method, yleft, yright, f, na.rm)
-#>
-#>
+#>
+#>
```
``` r
@@ -233,7 +233,7 @@ new_counter3()
#> i <- i + 1
#> i
#> }
-#>
+#>
```
``` r
@@ -243,8 +243,8 @@ new_counter3()
#> i <- i + 1
#> i
#> }
-#>
-#>
+#>
+#>
```
---
@@ -282,7 +282,7 @@ ggplot2::label_bquote
#> }
#> structure(fun, class = "labeller")
#> }
-#>
+#>
#>
```
@@ -305,7 +305,7 @@ scales::number_format
#> scale_cut = scale_cut, trim = trim, ...)
#> }
#> }
-#>
+#>
#>
```
@@ -401,7 +401,7 @@ Let's have a look at one example with each:
``` r
boxcox2(1)
#> function(x) (x^lambda - 1) / lambda
-#>
+#>
```
``` r
@@ -414,7 +414,7 @@ boxcox3(mtcars$wt)
#> (x^lambda - 1) / lambda
#> }
#> }
-#>
+#>
```
As can be seen:
@@ -447,7 +447,7 @@ boot_permute(mtcars, "mpg")
#> col <- df[[var]]
#> col[sample(n, replace = TRUE)]
#> }
-#>
+#>
```
This is why we don't need to worry about a copy being made because the `df` in the function environment points to the memory address of the data frame. We can confirm this by comparing their memory addresses:
@@ -456,7 +456,7 @@ This is why we don't need to worry about a copy being made because the `df` in t
``` r
boot_permute_env <- rlang::fn_env(boot_permute(mtcars, "mpg"))
rlang::env_print(boot_permute_env)
-#>
+#>
#> Parent:
#> Bindings:
#> • n:
@@ -521,8 +521,8 @@ bench::mark(
#> # A tibble: 2 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#>
-#> 1 LL1 28.8µs 30.7µs 31613. 12.8KB 41.1
-#> 2 LL2 15.5µs 16.6µs 57581. 0B 40.3
+#> 1 LL1 29µs 31.1µs 31435. 12.8KB 37.8
+#> 2 LL2 15.6µs 16.6µs 57061. 0B 34.3
```
As can be seen, the second version is much faster than the first version.
@@ -548,16 +548,16 @@ generate_ll_benches <- function(n) {
#> # A tibble: 10 × 5
#> length expression min median `itr/sec`
#>
-#> 1 10 LL1 40.5µs 42.4µs 22296.
-#> 2 10 LL2 18.5µs 19.3µs 50861.
-#> 3 20 LL1 43.2µs 44.7µs 22050.
-#> 4 20 LL2 17.9µs 18.6µs 53051.
-#> 5 50 LL1 47.6µs 48.9µs 20126.
-#> 6 50 LL2 17.1µs 17.8µs 55451.
-#> 7 100 LL1 63.2µs 65.4µs 14892.
-#> 8 100 LL2 18.4µs 19.1µs 51570.
-#> 9 1000 LL1 856µs 943.9µs 1087.
-#> 10 1000 LL2 56.9µs 58.2µs 16946.
+#> 1 10 LL1 41µs 43.4µs 22476.
+#> 2 10 LL2 18.8µs 19.9µs 48859.
+#> 3 20 LL1 42.7µs 45.3µs 20575.
+#> 4 20 LL2 18µs 18.8µs 52000.
+#> 5 50 LL1 47.6µs 49.7µs 19793.
+#> 6 50 LL2 17.2µs 18.1µs 54489.
+#> 7 100 LL1 62.9µs 65µs 15042.
+#> 8 100 LL2 18.3µs 19.2µs 50495.
+#> 9 1000 LL1 859.2µs 966.7µs 1051.
+#> 10 1000 LL2 56.8µs 58.9µs 16747.
```
``` r
@@ -714,8 +714,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -728,7 +728,7 @@ sessioninfo::session_info(include_base = TRUE)
#> colorspace 2.1-0 2023-01-23 [1] RSPM
#> compiler 4.4.1 2024-06-14 [3] local
#> datasets * 4.4.1 2024-06-14 [3] local
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> dplyr 1.1.4 2023-11-17 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
diff --git a/Function-factories_files/figure-html/Function-factories-28-1.png b/Function-factories_files/figure-html/Function-factories-28-1.png
index 5925d244..7825ff3a 100644
Binary files a/Function-factories_files/figure-html/Function-factories-28-1.png and b/Function-factories_files/figure-html/Function-factories-28-1.png differ
diff --git a/Function-operators.md b/Function-operators.md
index d8d22efb..49ca6d7f 100644
--- a/Function-operators.md
+++ b/Function-operators.md
@@ -97,7 +97,7 @@ possibly
#> })
#> }
#> }
-#>
+#>
#>
```
@@ -123,7 +123,7 @@ safely
#> check_bool(quiet)
#> function(...) capture_error(.f(...), otherwise, quiet)
#> }
-#>
+#>
#>
```
@@ -138,7 +138,7 @@ purrr:::capture_error
#> list(result = otherwise, error = e)
#> })
#> }
-#>
+#>
#>
```
@@ -290,10 +290,10 @@ withr::with_tempfile("logfile", code = {
cat(readLines(logfile), sep = "\n")
})
-#> Function created at: 2024-06-23 00:46:06.966535
-#> Function called at: 2024-06-23 00:46:11.973581
-#> Function called at: 2024-06-23 00:46:16.978954
-#> Function called at: 2024-06-23 00:46:24.987386
+#> Function created at: 2024-06-30 00:47:10.591292
+#> Function called at: 2024-06-30 00:47:15.5978
+#> Function called at: 2024-06-30 00:47:20.603245
+#> Function called at: 2024-06-30 00:47:28.611706
```
---
@@ -342,8 +342,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -354,7 +354,7 @@ sessioninfo::session_info(include_base = TRUE)
#> cli 3.6.3 2024-06-21 [1] RSPM
#> compiler 4.4.1 2024-06-14 [3] local
#> datasets * 4.4.1 2024-06-14 [3] local
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> dplyr 1.1.4 2023-11-17 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
diff --git a/Functionals.md b/Functionals.md
index 118c636a..2db90f91 100644
--- a/Functionals.md
+++ b/Functionals.md
@@ -39,7 +39,7 @@ map(x, 1)
as_mapper(1)
#> function (x, ...)
#> pluck_raw(x, list(1), .default = NULL)
-#>
+#>
```
``` r
@@ -56,7 +56,7 @@ map(x, list(2, 1))
as_mapper(list(2, 1))
#> function (x, ...)
#> pluck_raw(x, list(2, 1), .default = NULL)
-#>
+#>
```
``` r
@@ -80,7 +80,7 @@ map(y, "m")
as_mapper("m")
#> function (x, ...)
#> pluck_raw(x, list("m"), .default = NULL)
-#>
+#>
```
``` r
@@ -98,7 +98,7 @@ map(y, list(2, "m"))
as_mapper(list(2, "m"))
#> function (x, ...)
#> pluck_raw(x, list(2, "m"), .default = NULL)
-#>
+#>
```
``` r
@@ -175,7 +175,7 @@ map(1:3, runif(2))
as_mapper(runif(2))
#> function (x, ...)
#> pluck_raw(x, list(0.597890264587477, 0.587997315218672), .default = NULL)
-#>
+#>
```
---
@@ -976,7 +976,7 @@ library(rlang)
e <- env("x" = 1, "y" = 2)
rlang::env_print(e)
-#>
+#>
#> Parent:
#> Bindings:
#> • x:
@@ -1117,8 +1117,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -1129,7 +1129,7 @@ sessioninfo::session_info(include_base = TRUE)
#> cli 3.6.3 2024-06-21 [1] RSPM
#> compiler 4.4.1 2024-06-14 [3] local
#> datasets * 4.4.1 2024-06-14 [3] local
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> dplyr 1.1.4 2023-11-17 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
diff --git a/Functions.md b/Functions.md
index 8073939b..ff263749 100644
--- a/Functions.md
+++ b/Functions.md
@@ -20,7 +20,7 @@ library(tidyverse, warn.conflicts = FALSE)
match.fun("mean")
#> function (x, ...)
#> UseMethod("mean")
-#>
+#>
#>
```
@@ -388,7 +388,7 @@ names(primitives)
mean
#> function (x, ...)
#> UseMethod("mean")
-#>
+#>
#>
```
@@ -400,7 +400,7 @@ purrr::map
#> {
#> map_("list", .x, .f, ..., .progress = .progress)
#> }
-#>
+#>
#>
```
@@ -615,7 +615,7 @@ f2 <- function(x = z) {
}
f2()
-#> [1] "0x5594a18faf60" "0x5594a18faf60"
+#> [1] "0x55a6dfd73a28" "0x55a6dfd73a28"
#> [1] 100
```
@@ -713,7 +713,7 @@ show_time <- function(x = stop("Error!")) {
}
show_time()
-#> [1] "2024-06-23 00:45:53 UTC"
+#> [1] "2024-06-30 00:46:57 UTC"
```
**A5.** Let's take this step-by-step.
@@ -948,7 +948,7 @@ withr::with_dir
#> on.exit(setwd(old))
#> force(code)
#> }
-#>
+#>
#>
```
@@ -1030,7 +1030,7 @@ capture.output
#> close(file)
#> rval %||% invisible(NULL)
#> }
-#>
+#>
#>
```
@@ -1403,8 +1403,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -1416,7 +1416,7 @@ sessioninfo::session_info(include_base = TRUE)
#> colorspace 2.1-0 2023-01-23 [1] RSPM
#> compiler 4.4.1 2024-06-14 [3] local
#> datasets * 4.4.1 2024-06-14 [3] local
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> dplyr * 1.1.4 2023-11-17 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
diff --git a/Names-values.md b/Names-values.md
index d2862d65..29c2216e 100644
--- a/Names-values.md
+++ b/Names-values.md
@@ -29,7 +29,7 @@ d <- 1:10
``` r
obj_addrs <- obj_addrs(list(a, b, c))
unique(obj_addrs)
-#> [1] "0x55645d867998"
+#> [1] "0x55f70ec545b0"
```
Except `d`, which is a different object, even if it has the same value as `a`, `b`, and `c`:
@@ -37,7 +37,7 @@ Except `d`, which is a different object, even if it has the same value as `a`, `
``` r
obj_addr(d)
-#> [1] "0x55645dc7f658"
+#> [1] "0x55f70e7fb840"
```
---
@@ -66,7 +66,7 @@ obj_addrs <- obj_addrs(list(
))
unique(obj_addrs)
-#> [1] "0x55645ba48c00"
+#> [1] "0x55f70c21d580"
```
---
@@ -124,7 +124,7 @@ And as the docs mention (emphasis mine):
x <- 1:10
tracemem(x)
-#> [1] "<0x55645ec51bc0>"
+#> [1] "<0x55f7105e5a10>"
```
``` r
@@ -139,13 +139,13 @@ But since the object created in memory by `1:10` is not assigned a name, it can'
``` r
obj_addr(1:10)
-#> [1] "0x55645f5b2118"
+#> [1] "0x55f71016f5d8"
```
``` r
tracemem(1:10)
-#> [1] "<0x55645ee71420>"
+#> [1] "<0x55f7101db110>"
```
---
@@ -172,14 +172,14 @@ typeof(x)
``` r
tracemem(x)
-#> [1] "<0x55645fa4fe78>"
+#> [1] "<0x55f7109c6738>"
```
``` r
x[[3]] <- 4
-#> tracemem[0x55645fa4fe78 -> 0x55645fb87538]: eval eval eval_with_user_handlers withVisible withCallingHandlers handle timing_fn evaluate_call evaluate in_dir in_input_dir eng_r block_exec call_block process_group withCallingHandlers process_file do.call eval eval eval eval eval.parent local
-#> tracemem[0x55645fb87538 -> 0x55645fb28a18]: eval eval eval_with_user_handlers withVisible withCallingHandlers handle timing_fn evaluate_call evaluate in_dir in_input_dir eng_r block_exec call_block process_group withCallingHandlers process_file do.call eval eval eval eval eval.parent local
+#> tracemem[0x55f7109c6738 -> 0x55f710aec5d8]: eval eval eval_with_user_handlers withVisible withCallingHandlers handle timing_fn evaluate_call evaluate in_dir in_input_dir eng_r block_exec call_block process_group withCallingHandlers process_file do.call eval eval eval eval eval.parent local
+#> tracemem[0x55f710aec5d8 -> 0x55f710ac9d38]: eval eval eval_with_user_handlers withVisible withCallingHandlers handle timing_fn evaluate_call evaluate in_dir in_input_dir eng_r block_exec call_block process_group withCallingHandlers process_file do.call eval eval eval eval eval.parent local
```
``` r
@@ -200,13 +200,13 @@ typeof(x)
``` r
tracemem(x)
-#> [1] "<0x5564601ae958>"
+#> [1] "<0x55f710f272d8>"
```
``` r
x[[3]] <- 4L
-#> tracemem[0x5564601ae958 -> 0x5564602e01b8]: eval eval eval_with_user_handlers withVisible withCallingHandlers handle timing_fn evaluate_call evaluate in_dir in_input_dir eng_r block_exec call_block process_group withCallingHandlers process_file do.call eval eval eval eval eval.parent local
+#> tracemem[0x55f710f272d8 -> 0x55f711056c18]: eval eval eval_with_user_handlers withVisible withCallingHandlers handle timing_fn evaluate_call evaluate in_dir in_input_dir eng_r block_exec call_block process_group withCallingHandlers process_file do.call eval eval eval eval eval.parent local
```
``` r
@@ -240,26 +240,26 @@ b <- list(a, a)
c <- list(b, a, 1:10)
ref(a)
-#> [1:0x5564609ea928]
+#> [1:0x55f711770c28]
```
``` r
ref(b)
-#> █ [1:0x5564609d9e38]
-#> ├─[2:0x5564609ea928]
-#> └─[2:0x5564609ea928]
+#> █ [1:0x55f711756638]
+#> ├─[2:0x55f711770c28]
+#> └─[2:0x55f711770c28]
```
``` r
ref(c)
-#> █ [1:0x556460f58848]
-#> ├─█ [2:0x5564609d9e38]
-#> │ ├─[3:0x5564609ea928]
-#> │ └─[3:0x5564609ea928]
-#> ├─[3:0x5564609ea928]
-#> └─[4:0x556460fba218]
+#> █ [1:0x55f711d19f58]
+#> ├─█ [2:0x55f711756638]
+#> │ ├─[3:0x55f711770c28]
+#> │ └─[3:0x55f711770c28]
+#> ├─[3:0x55f711770c28]
+#> └─[4:0x55f711d3c6d8]
```
Here is what we learn:
@@ -292,7 +292,7 @@ x
``` r
obj_addr(x)
-#> [1] "0x556461162190"
+#> [1] "0x55f711f25008"
```
``` r
@@ -309,16 +309,16 @@ x
``` r
obj_addr(x)
-#> [1] "0x5564608c0058"
+#> [1] "0x55f711182d58"
```
``` r
ref(x)
-#> █ [1:0x5564608c0058]
-#> ├─[2:0x556460fa4c98]
-#> └─█ [3:0x556461162190]
-#> └─[2:0x556460fa4c98]
+#> █ [1:0x55f711182d58]
+#> ├─[2:0x55f711d55178]
+#> └─█ [3:0x55f711f25008]
+#> └─[2:0x55f711d55178]
```
I don't have access to OmniGraffle software, so I am including here the figure from the [official solution manual](https://advanced-r-solutions.rbind.io/names-and-values.html#copy-on-modify):
@@ -488,25 +488,25 @@ x[[1]] <- x
x <- list()
obj_addr(x)
-#> [1] "0x5564614da2e0"
+#> [1] "0x55f712270d80"
```
``` r
tracemem(x)
-#> [1] "<0x5564614da2e0>"
+#> [1] "<0x55f712270d80>"
```
``` r
x[[1]] <- x
-#> tracemem[0x5564614da2e0 -> 0x5564615e45c0]: eval eval eval_with_user_handlers withVisible withCallingHandlers handle timing_fn evaluate_call evaluate in_dir in_input_dir eng_r block_exec call_block process_group withCallingHandlers process_file do.call eval eval eval eval eval.parent local
+#> tracemem[0x55f712270d80 -> 0x55f70f1faef0]: eval eval eval_with_user_handlers withVisible withCallingHandlers handle timing_fn evaluate_call evaluate in_dir in_input_dir eng_r block_exec call_block process_group withCallingHandlers process_file do.call eval eval eval eval eval.parent local
```
``` r
obj_addr(x[[1]])
-#> [1] "0x5564614da2e0"
+#> [1] "0x55f712270d80"
```
---
@@ -630,8 +630,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -645,7 +645,7 @@ sessioninfo::session_info(include_base = TRUE)
#> compiler 4.4.1 2024-06-14 [3] local
#> crayon 1.5.3 2024-06-20 [1] RSPM
#> datasets * 4.4.1 2024-06-14 [3] local
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> dplyr * 1.1.4 2023-11-17 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
diff --git a/Names-values_files/figure-html/Names-values-31-1.png b/Names-values_files/figure-html/Names-values-31-1.png
index f104d68f..028a186a 100644
Binary files a/Names-values_files/figure-html/Names-values-31-1.png and b/Names-values_files/figure-html/Names-values-31-1.png differ
diff --git a/Perf-improve.md b/Perf-improve.md
index 3160195a..cdc1aa04 100644
--- a/Perf-improve.md
+++ b/Perf-improve.md
@@ -70,10 +70,10 @@ bench::mark(
#> # A tibble: 4 × 5
#> expression min median `itr/sec` mem_alloc
#>
-#> 1 lm 849.78µs 879.1µs 1112. 1.26MB
-#> 2 speedglm 1.54ms 1.57ms 633. 70.75MB
-#> 3 biglm 758.27µs 784.04µs 1202. 589.44KB
-#> 4 fastLm 1.03ms 1.06ms 931. 4.53MB
+#> 1 lm 857.3µs 887.23µs 1102. 1.26MB
+#> 2 speedglm 1.54ms 1.59ms 628. 70.75MB
+#> 3 biglm 759.05µs 782.37µs 1244. 589.44KB
+#> 4 fastLm 1.03ms 1.06ms 933. 4.53MB
```
The results might change depending on the size of the dataset, with the performance benefits accruing bigger the dataset.
@@ -109,8 +109,8 @@ bench::mark(
#> # A tibble: 2 × 5
#> expression min median `itr/sec` mem_alloc
#>
-#> 1 base 1.2µs 1.25µs 739659. 2.8KB
-#> 2 fastmatch 1.11µs 1.17µs 804292. 2.66KB
+#> 1 base 1.18µs 1.24µs 751338. 2.8KB
+#> 2 fastmatch 1.09µs 1.13µs 829169. 2.66KB
```
But, with a larger vector, `fmatch()` is orders of magnitude faster! ⚡
@@ -134,8 +134,8 @@ bench::mark(
#> # A tibble: 2 × 5
#> expression min median `itr/sec` mem_alloc
#>
-#> 1 base 23.7ms 25.59ms 29.0 31.4MB
-#> 2 fastmatch 1.1µs 1.17µs 818551. 0B
+#> 1 base 25.37ms 29.29ms 25.7 31.4MB
+#> 2 fastmatch 1.08µs 1.12µs 857604. 0B
```
We can also look at the hash table:
@@ -217,10 +217,10 @@ bench::mark(
#> # A tibble: 4 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#>
-#> 1 as.POSIXct 29.18µs 31.6µs 28090. 0B 28.1
-#> 2 as.POSIXlt 20.05µs 20.94µs 47169. 0B 0
-#> 3 ymd_hms 2.17ms 2.25ms 445. 21.5KB 4.04
-#> 4 fastPOSIXct 1.25µs 1.31µs 721865. 0B 0
+#> 1 as.POSIXct 28.68µs 40.1µs 25389. 0B 25.4
+#> 2 as.POSIXlt 19.76µs 20.76µs 47435. 0B 0
+#> 3 ymd_hms 2.2ms 2.28ms 437. 21.5KB 3.97
+#> 4 fastPOSIXct 1.26µs 1.31µs 723278. 0B 0
```
There are many more packages that implement a way to convert from string to a date time object. For more, see [CRAN Task View: Time Series Analysis](https://cran.r-project.org/web/views/TimeSeries.html)
@@ -281,7 +281,7 @@ rowSums
#> else names(z) <- dimnames(x)[[1L]]
#> z
#> }
-#>
+#>
#>
```
@@ -292,7 +292,7 @@ rowSums
.rowSums
#> function (x, m, n, na.rm = FALSE)
#> .Internal(rowSums(x, m, n, na.rm))
-#>
+#>
#>
```
@@ -309,8 +309,8 @@ bench::mark(
#> # A tibble: 2 × 5
#> expression min median `itr/sec` mem_alloc
#>
-#> 1 rowSums 823µs 860µs 1120. 859KB
-#> 2 .rowSums 818µs 857µs 1163. 859KB
+#> 1 rowSums 820µs 856µs 1148. 859KB
+#> 2 .rowSums 817µs 852µs 1172. 859KB
```
**Q2.** Make a faster version of `chisq.test()` that only computes the chi-square test statistic when the input is two numeric vectors with no missing values. You can try simplifying `chisq.test()` or by coding from the [mathematical definition](http://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test).
@@ -377,8 +377,8 @@ bench::mark(
#> # A tibble: 2 × 5
#> expression min median `itr/sec` mem_alloc
#>
-#> 1 base 879µs 902µs 1102. 1.57MB
-#> 2 custom 685µs 701µs 1414. 5.3MB
+#> 1 base 885µs 909µs 1090. 1.57MB
+#> 2 custom 693µs 709µs 1398. 5.3MB
```
**Q3.** Can you make a faster version of `table()` for the case of an input of two integer vectors with no missing values? Can you use it to speed up your chi-square test?
@@ -435,8 +435,8 @@ bench::mark(
#> # A tibble: 2 × 5
#> expression min median `itr/sec` mem_alloc
#>
-#> 1 base 614µs 627µs 1584. 960KB
-#> 2 custom 349µs 355µs 2771. 489KB
+#> 1 base 623µs 639µs 1555. 960KB
+#> 2 custom 352µs 359µs 2761. 489KB
```
We can also use this function in our custom chi-squared test function and see if the performance improves any further:
@@ -494,8 +494,8 @@ bench::mark(
#> # A tibble: 2 × 5
#> expression min median `itr/sec` mem_alloc
#>
-#> 1 base 884µs 915µs 1085. 1.28MB
-#> 2 custom 411µs 421µs 2347. 593.61KB
+#> 1 base 893µs 928µs 1070. 1.28MB
+#> 2 custom 418µs 427µs 2304. 593.61KB
```
## Exercises 24.5.1
@@ -621,6 +621,6 @@ bench::mark(
#> # A tibble: 2 × 5
#> expression min median `itr/sec` mem_alloc
#>
-#> 1 crossprod(x, w)[[1]] 410ns 451ns 2052073. 0B
-#> 2 sum(x * w)[[1]] 470ns 531ns 1717459. 0B
+#> 1 crossprod(x, w)[[1]] 420ns 452ns 2018928. 0B
+#> 2 sum(x * w)[[1]] 460ns 521ns 1737318. 0B
```
diff --git a/Perf-improve_files/figure-html/Perf-improve-28-1.png b/Perf-improve_files/figure-html/Perf-improve-28-1.png
index ee0d9c79..dcc260de 100644
Binary files a/Perf-improve_files/figure-html/Perf-improve-28-1.png and b/Perf-improve_files/figure-html/Perf-improve-28-1.png differ
diff --git a/Perf-measure.md b/Perf-measure.md
index 098f0c67..4b3e0ea2 100644
--- a/Perf-measure.md
+++ b/Perf-measure.md
@@ -68,7 +68,7 @@ rm
#> }
#> .Internal(remove(list, envir, inherits))
#> }
-#>
+#>
#>
```
@@ -144,8 +144,8 @@ full_join(t_bench_df, t_systime_df, by = "expression")
#> # A tibble: 2 × 4
#> expression bench_mean systime_with_gc systime_with_nogc
#>
-#> 1 sqrt(x) 649.17ns 0.662 0.419
-#> 2 x^0.5 2.17µs 2.01 1.98
+#> 1 sqrt(x) 684.44ns 0.682 0.432
+#> 2 x^0.5 2.22µs 2.01 1.98
```
The comparison reveals that these two approaches yield quite similar results. Slight differences in exact values is possibly due to differences in the precision of timers used internally by these functions.
@@ -180,10 +180,10 @@ bench::mark(
#> # A tibble: 4 × 2
#> expression median
#>
-#> 1 sqrt(x) 3.03µs
-#> 2 exp(log(x)/2) 12.64µs
-#> 3 x^0.5 18.82µs
-#> 4 x^(1/2) 18.93µs
+#> 1 sqrt(x) 3.04µs
+#> 2 exp(log(x)/2) 12.63µs
+#> 3 x^0.5 18.86µs
+#> 4 x^(1/2) 18.99µs
```
The specialized primitive function `sqrt()` (written in `C`) is the fastest way to compute square root.
@@ -205,8 +205,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -218,7 +218,7 @@ sessioninfo::session_info(include_base = TRUE)
#> cli 3.6.3 2024-06-21 [1] RSPM
#> compiler 4.4.1 2024-06-14 [3] local
#> datasets * 4.4.1 2024-06-14 [3] local
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> dplyr * 1.1.4 2023-11-17 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
diff --git a/Quotation.md b/Quotation.md
index 16468687..ba0854e3 100644
--- a/Quotation.md
+++ b/Quotation.md
@@ -177,7 +177,7 @@ rlang::expr
#> {
#> enexpr(expr)
#> }
-#>
+#>
#>
```
@@ -199,7 +199,7 @@ rlang::enexpr
#> {
#> .Call(ffi_enexpr, substitute(arg), parent.frame())
#> }
-#>
+#>
#>
```
@@ -914,8 +914,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz UTC
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -929,7 +929,7 @@ sessioninfo::session_info(include_base = TRUE)
#> crayon 1.5.3 2024-06-20 [1] RSPM
#> datasets * 4.4.1 2024-06-14 [3] local
#> diffobj 0.3.5 2021-10-05 [1] RSPM
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> dplyr * 1.1.4 2023-11-17 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
diff --git a/R6.md b/R6.md
index 498d2293..5366c5dd 100644
--- a/R6.md
+++ b/R6.md
@@ -312,7 +312,7 @@ typeof(myExample)
``` r
rlang::env_print(myExample)
-#> [L]
+#> [L]
#> Parent:
#> Class: Example, R6
#> Bindings:
@@ -609,8 +609,8 @@ greetMom()
gc()
#> [1] "Closing the file connection!"
#> used (Mb) gc trigger (Mb) max used (Mb)
-#> Ncells 760537 40.7 1418781 75.8 1418781 75.8
-#> Vcells 1401701 10.7 8388608 64.0 2664742 20.4
+#> Ncells 760591 40.7 1418938 75.8 1418938 75.8
+#> Vcells 1401802 10.7 8388608 64.0 2665524 20.4
```
## Session information
@@ -628,8 +628,8 @@ sessioninfo::session_info(include_base = TRUE)
#> collate C.UTF-8
#> ctype C.UTF-8
#> tz Europe/Berlin
-#> date 2024-06-23
-#> pandoc 3.2 @ /opt/hostedtoolcache/pandoc/3.2/x64/ (via rmarkdown)
+#> date 2024-06-30
+#> pandoc 3.2.1 @ /opt/hostedtoolcache/pandoc/3.2.1/x64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────
#> package * version date (UTC) lib source
@@ -640,7 +640,7 @@ sessioninfo::session_info(include_base = TRUE)
#> cli 3.6.3 2024-06-21 [1] RSPM
#> compiler 4.4.1 2024-06-14 [3] local
#> datasets * 4.4.1 2024-06-14 [3] local
-#> digest 0.6.35 2024-03-11 [1] RSPM
+#> digest 0.6.36 2024-06-23 [1] RSPM
#> downlit 0.4.4 2024-06-10 [1] RSPM
#> evaluate 0.24.0 2024-06-10 [1] RSPM
#> fansi 1.0.6 2023-12-08 [1] RSPM
diff --git a/Rcpp.md b/Rcpp.md
index cce79f92..5e0323bf 100644
--- a/Rcpp.md
+++ b/Rcpp.md
@@ -261,12 +261,12 @@ bench::mark(
#> # A tibble: 2 × 6
#> expression min
#>
-#> 1 all(c(rep(TRUE, 1000), rep(FALSE, 1000))) 6.03µs
-#> 2 allC(c(rep(TRUE, 1000), rep(FALSE, 1000))) 7.92µs
+#> 1 all(c(rep(TRUE, 1000), rep(FALSE, 1000))) 6.11µs
+#> 2 allC(c(rep(TRUE, 1000), rep(FALSE, 1000))) 7.91µs
#> median `itr/sec` mem_alloc `gc/sec`
#>
-#> 1 6.42µs 154527. 15.8KB 0
-#> 2 8.21µs 118273. 15.8KB 0
+#> 1 6.57µs 150278. 15.8KB 0
+#> 2 8.24µs 115567. 15.8KB 0
```
- `cumprod()`
@@ -314,8 +314,8 @@ bench::mark(
#> # A tibble: 2 × 6
#> expression min median `itr/sec` mem_alloc
#>
-#> 1 cumprod(v1) 100ns 110ns 7548273. 0B
-#> 2 cumprodC(v1) 731ns 832ns 1119786. 4.12KB
+#> 1 cumprod(v1) 100ns 110ns 7584730. 0B
+#> 2 cumprodC(v1) 741ns 782ns 879818. 4.12KB
#> `gc/sec`
#>
#> 1 0
@@ -367,8 +367,8 @@ bench::mark(
#> # A tibble: 2 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#>
-#> 1 cummin(v1) 110ns 130ns 6313761. 0B 0
-#> 2 cumminC(v1) 832ns 882ns 1002574. 4.12KB 0
+#> 1 cummin(v1) 120ns 130ns 6609727. 0B 0
+#> 2 cumminC(v1) 822ns 892ns 1008130. 4.12KB 0
```
- `cummaxC()`
@@ -416,8 +416,8 @@ bench::mark(
#> # A tibble: 2 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#>