10.qmd (3666B)
1 --- 2 title: Cohort 10 3 --- 4 5 {{< video https://www.youtube.com/embed/_GIEEMuZYrs >}} 6 7 <details> 8 9 <summary>Meeting chat log</summary> 10 ``` 11 00:07:45 Stephan Koenig: Isn’t it just F from revealjs? 12 00:08:06 Gabby Palomo: Reacted to "Isn’t it just F from..." with 👍 13 00:08:11 Jon Harmon (jonthegeek): start 14 00:09:01 Jon Harmon (jonthegeek): https://adv-r.hadley.nz/names-values.html 15 https://DSLC.io/advr 16 https://r4ds.github.io/bookclub-advr/slides/02.html#/learning-objectives 17 00:13:10 Jon Harmon (jonthegeek): R lets you do really insane things as long as you put it in ticks: 18 [main 12:07:10] > `function` <- mean 19 [main 12:07:53] > function(x) {x + 1} 20 Warning message: 21 In mean.default(as.pairlist(alist(x = )), { : 22 argument is not numeric or logical: returning NA 23 [1] NA 24 00:18:15 Stephan Koenig: What happens with 1L:10L? 25 00:18:33 Josh Persi: Replying to "What happens with 1L..." 26 27 I had the same question! 28 00:23:32 Jon Harmon (jonthegeek): Went off on a tangent. Currently running this. No limit so far! 29 var_name_start <- "x" 30 var_characters <- 1L 31 var_name <- paste(rep(var_name_start, var_characters), collapse = "") 32 assign(var_name, var_characters) 33 max_characters <- 99999L 34 while (get(var_name) == var_characters && var_characters <= max_characters) { 35 cli::cli_inform( 36 "{var_name} works!" 37 ) 38 var_characters <- var_characters + 1L 39 var_name <- paste(rep(var_name_start, var_characters), collapse = "") 40 assign(var_name, var_characters) 41 } 42 00:24:41 Jon Harmon (jonthegeek): Found the limit (with assign() at least): 43 Error in `assign()`: 44 ! variable names are limited to 10000 bytes 45 00:26:27 Retselisitsoe Monyake: Replying to "What happens with 1L..." 46 47 > a <- 1L:10L 48 > b <- 1L:10L 49 > lobstr::obj_addr(a) 50 [1] "0x19ea1229788" 51 > lobstr::obj_addr(b) 52 [1] "0x19ea0a4e148" 53 54 Look like it gives different addresses 55 00:26:57 Stephan Koenig: Replying to "What happens with 1L…" 56 Thanks! 57 00:27:07 Stephan Koenig: Reacted to "> a <- 1L:10L 58 > b <-…" with 👍 59 00:28:25 tataphani: Reacted to "> a <- 1L:10L 60 > b <-..." with 👍 61 00:44:40 Stephan Koenig: So a character vectors acts much more like a list? 62 00:52:44 Stephan Koenig: So does the ALTREP stop if you change a single element for example in y? 63 00:52:44 Jon Harmon (jonthegeek): This helps show the efficiency: 64 [main 12:47:24] > obj_size(1:10) 65 680 B 66 [main 12:47:38] > obj_size(as.list(1:10)) 67 736 B 68 [main 12:47:45] > obj_size(1:100) 69 680 B 70 [main 12:47:50] > obj_size(as.list(1:100)) 71 6.45 kB 72 [main 12:47:53] > obj_size(1:1000) 73 680 B 74 [main 12:48:20] > obj_size(as.list(1:1000)) 75 64.05 kB 76 00:54:34 Jon Harmon (jonthegeek): [main 12:49:54] > x <- 1:100 77 [main 12:50:13] > obj_size(x) 78 680 B 79 [main 12:50:16] > x[[1]] <- 2 80 [main 12:50:27] > obj_size(x) 81 848 B 82 00:55:04 Eamon Caddigan: x <- 2^(1:1e1) 83 y <- 2^(1:1e4) 84 obj_size(x) 85 #> 176 B 86 obj_size(y) 87 #> 80.05 kB 88 00:56:17 Eamon Caddigan: Like how Python went from range to xrange back to range 89 00:56:27 Stephan Koenig: Can we inspect what ALTREP R is using for an object? 90 00:57:07 Jon Harmon (jonthegeek): Replying to "Can we inspect what ..." 91 92 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. 93 00:57:39 Stephan Koenig: Reacted to "Not as far as I know…" with 👍 94 01:00:54 Eamon Caddigan: “Cons cells”? I low-key love when R shows its Lispyness. 95 01:01:53 Jon Harmon (jonthegeek): stop 96 01:02:09 Zachary Morford: Thank you all! I have to run but I'll be there next week. 97 01:02:16 Stephan Koenig: Thanks, Nick! 98 01:02:58 Jon Harmon (jonthegeek): https://github.com/r4ds/bookclub-advr?tab=readme-ov-file#how-to-present 99 01:03:39 Jon Harmon (jonthegeek): usethis::edit_r_profile() 100 ``` 101 </details>