Cohort 10

Meeting chat log
00:07:45    Stephan Koenig: Isn’t it just F from revealjs?
00:08:06    Gabby Palomo:   Reacted to "Isn’t it just F from..." with 👍
00:08:11    Jon Harmon (jonthegeek):    start
00:09:01    Jon Harmon (jonthegeek):    https://adv-r.hadley.nz/names-values.html 
https://DSLC.io/advr 
https://r4ds.github.io/bookclub-advr/slides/02.html#/learning-objectives
00:13:10    Jon Harmon (jonthegeek):    R lets you do really insane things as long as you put it in ticks:
[main 12:07:10] > `function` <- mean
[main 12:07:53] > function(x) {x + 1}
Warning message:
In mean.default(as.pairlist(alist(x = )), { :
  argument is not numeric or logical: returning NA
[1] NA
00:18:15    Stephan Koenig: What happens with 1L:10L?
00:18:33    Josh Persi: Replying to "What happens with 1L..."

I had the same question!
00:23:32    Jon Harmon (jonthegeek):    Went off on a tangent. Currently running this. No limit so far!
var_name_start <- "x"
var_characters <- 1L
var_name <- paste(rep(var_name_start, var_characters), collapse = "")
assign(var_name, var_characters)
max_characters <- 99999L
while (get(var_name) == var_characters && var_characters <= max_characters) {
  cli::cli_inform(
    "{var_name} works!"
  )
  var_characters <- var_characters + 1L
  var_name <- paste(rep(var_name_start, var_characters), collapse = "")
  assign(var_name, var_characters)
}
00:24:41    Jon Harmon (jonthegeek):    Found the limit (with  assign()  at least):
Error in `assign()`:
! variable names are limited to 10000 bytes
00:26:27    Retselisitsoe Monyake:  Replying to "What happens with 1L..."

> a <- 1L:10L
> b <- 1L:10L
> lobstr::obj_addr(a)
[1] "0x19ea1229788"
> lobstr::obj_addr(b)
[1] "0x19ea0a4e148"

Look like it gives different addresses
00:26:57    Stephan Koenig: Replying to "What happens with 1L…"
Thanks!
00:27:07    Stephan Koenig: Reacted to "> a <- 1L:10L
> b <-…" with 👍
00:28:25    tataphani:  Reacted to "> a <- 1L:10L
> b <-..." with 👍
00:44:40    Stephan Koenig: So a character vectors acts much more like a list?
00:52:44    Stephan Koenig: So does the ALTREP stop if you change a single element for example in y?
00:52:44    Jon Harmon (jonthegeek):    This helps show the efficiency:
[main 12:47:24] > obj_size(1:10)
680 B
[main 12:47:38] > obj_size(as.list(1:10))
736 B
[main 12:47:45] > obj_size(1:100)
680 B
[main 12:47:50] > obj_size(as.list(1:100))
6.45 kB
[main 12:47:53] > obj_size(1:1000)
680 B
[main 12:48:20] > obj_size(as.list(1:1000))
64.05 kB
00:54:34    Jon Harmon (jonthegeek):    [main 12:49:54] > x <- 1:100
[main 12:50:13] > obj_size(x)
680 B
[main 12:50:16] > x[[1]] <- 2
[main 12:50:27] > obj_size(x)
848 B
00:55:04    Eamon Caddigan: x <- 2^(1:1e1)
y <- 2^(1:1e4)
obj_size(x)
#> 176 B
obj_size(y)
#> 80.05 kB
00:56:17    Eamon Caddigan: Like how Python went from range to xrange back to range
00:56:27    Stephan Koenig: Can we inspect what ALTREP R is using for an object?
00:57:07    Jon Harmon (jonthegeek):    Replying to "Can we inspect what ..."

Not as far as I know, or at least not easily. We might learn how to do that toward the end when we learn about the C interface.
00:57:39    Stephan Koenig: Reacted to "Not as far as I know…" with 👍
01:00:54    Eamon Caddigan: “Cons cells”? I low-key love when R shows its Lispyness.
01:01:53    Jon Harmon (jonthegeek):    stop
01:02:09    Zachary Morford:    Thank you all! I have to run but I'll be there next week.
01:02:16    Stephan Koenig: Thanks, Nick!
01:02:58    Jon Harmon (jonthegeek):    https://github.com/r4ds/bookclub-advr?tab=readme-ov-file#how-to-present
01:03:39    Jon Harmon (jonthegeek):    usethis::edit_r_profile()