10.qmd (5873B)
1 --- 2 title: Cohort 10 3 --- 4 5 {{< video https://www.youtube.com/embed/HRL1EursTR8 >}} 6 7 <details> 8 9 <summary>Meeting chat log</summary> 10 ``` 11 00:10:11 Jon Harmon (jonthegeek): start 12 00:16:09 Stephan Koenig: You can reassign `T` and `F` to other objects. so `TRUE` and `FALSE` more robust 13 00:16:25 Eamon Caddigan: Replying to "You can reassign `T`..." 14 15 Oh, TIL! 16 00:16:31 Sally Chang: Reacted to "Oh, TIL!" with ➕ 17 00:16:43 Retselisitsoe Monyake: Reacted to "You can reassign `..." with 👍 18 00:19:41 Jon Harmon (jonthegeek): If you think of NA as "unknown" I feel like all of the rules make sense. 19 00:19:55 Nicholas Giangreco: Reacted to "If you think of NA a..." with 👍 20 00:20:13 Derek Sollberger: Replying to "If you think of NA a..." 21 22 Makes less sense when "NA" is "North America" --- Data Mishaps Night 23 00:20:24 Ella Kaye (she/her): Reacted to "Makes less sense whe..." with 😂 24 00:22:33 Jon Harmon (jonthegeek): https://DSLC.io/advr 25 00:32:31 Nicholas Giangreco: attr(a, “bob”) <- bob 26 00:35:53 Jon Harmon (jonthegeek): lobstr::obj_addr() 27 00:40:17 Eamon Caddigan: ``` 28 bob <- "bob" 29 alice <- "alice" 30 attr(alice, "friend") <- bob 31 attr(bob, "friend") <- alice 32 str(bob) 33 #> chr "bob" 34 #> - attr(*, "friend")= chr "alice" 35 str(alice) 36 #> chr "alice" 37 #> - attr(*, "friend")= chr "bob" 38 ref(bob) 39 #> [1:0x1098bebc8] <chr> 40 ref(attr(alice, "friend")) 41 #> [1:0x109883960] <chr> 42 ``` 43 00:41:18 Eamon Caddigan: Replying to "attr(a, “bob”) <- bo..." 44 45 Does this get at what you were asking about? It looks like bob is getting a new address when it gets modified, so Alice’s friend points to the original bob . 46 00:42:39 Stephan Koenig: I never understood the difference between an ordered factor and a regular one. Even the regular factor has an order to the levels, no? 47 00:43:38 Jon Harmon (jonthegeek): If you don't give it a tz, it leaves the tz as "" then assumes local when you use it, most of the time, if I recall correctly. That's one of the many things lubridate fixes 48 00:45:32 Jon Harmon (jonthegeek): Replying to "I never understood t..." 49 50 Looks like the concept of "ordered" is largely leftover from S. Oh, and they say some other things might treat them differently. 51 00:45:54 Stephan Koenig: Reacted to "Looks like the conce..." with 🙏 52 00:45:58 Nicholas Giangreco: Replying to "I never understood t..." 53 54 An ordered factor has an extra class of “ordered” 55 00:46:21 Stephan Koenig: Reacted to "An ordered factor ha..." with 👍 56 00:46:37 Ella Kaye (she/her): Replying to "I never understood t..." 57 58 It’s relevant in some modelling contexts. I know I made use of them in my MSc, to represent student grade levels, but that was a while ago now and I can’t remember exactly what modelling I did. 59 00:48:00 Eamon Caddigan: Replying to "I never understood t..." 60 61 The default contrasts for ordered factors are polynomial, and they’re dummy-coded for non-ordered factors. 62 00:48:10 Eamon Caddigan: Reacted to "It’s relevant in som..." with 💯 63 00:48:17 Stephan Koenig: Reacted to "It’s relevant in som..." with 🙏 64 00:48:22 Stephan Koenig: Reacted to "The default contras..." with 🙏 65 00:51:26 Eamon Caddigan: If you find yourself writing a big loop and storing things in a list, you’ll want to preallocate an empty list, imho. Use vector(mode=“list”, length=<length>) 66 00:51:42 Nicholas Giangreco: Reacted to "If you find yourself..." with 👍 67 00:51:52 Retselisitsoe Monyake: Reacted to "If you find yourse..." with 👍 68 00:53:03 Stephan Koenig: Replying to "If you find yourself..." 69 70 Why does that make a difference? I thought a list just contains pointers anyway. 71 00:53:07 Jon Harmon (jonthegeek): Replying to "If you find yourself..." 72 73 Yes, but within the last couple years they made this much less important, if I recall correctly. 74 00:54:16 Sarah Rathwell: Replying to "If you find yourself..." 75 76 Is there a reason to use that over list() ? I know the vector call version pre-specifies length but if you do know the desired length beforehand are the two methods different 77 00:54:53 Stephan Koenig: tibble recycles the length of one 78 00:55:08 Jon Harmon (jonthegeek): Replying to "If you find yourself..." 79 80 Use vector() when you know you want a list with a certain length but you don't know what goes in it. If you're building a list with specified values, list() is fine. 81 00:56:53 Eamon Caddigan: Reacted to "Use vector() when yo..." with 💯 82 00:56:53 Jon Harmon (jonthegeek): data.frame(x = 1:4, y = 1:2) 83 tibble(x = 1:4, y = 1:2) 84 00:59:34 Stephan Koenig: Data frames do partial matching. 85 01:00:49 Stephan Koenig: What is the `I` function? 86 01:01:05 Eamon Caddigan: Replying to "If you find yourself..." 87 88 I’d defer to our other experts on R internals, but I believe that lists are “generic vectors” (of pointers to objects), but they’re not (e.g.) linked lists. So if you’re appending to them repeatedly eventually the whole vector of pointers is going to be copied to a new region of memory. 89 01:01:26 Stephan Koenig: Reacted to "I’d defer to our oth..." with 🙏 90 01:02:11 Eamon Caddigan: Replying to "If you think of NA a..." 91 92 I was recently burned by (not knowing about the default values of) the na argument to readr::read_csv . 93 01:02:30 Jon Harmon (jonthegeek): testing <- data.frame() 94 nrow(testing) 95 96 testing <- NULL 97 nrow(testing) 98 NROW(testing) # Yell at R to give you an answer. 99 01:03:18 Eamon Caddigan: Reacted to "testing <- data.fram..." with 😂 100 01:03:21 Nicholas Giangreco: Reacted to "testing <- data.fram..." with ❗ 101 01:05:15 Jacob Schwan: Reacted to "testing <- data.fram..." with 😂 102 01:07:35 Stephan Koenig: Thank you, Olivier! 103 01:07:39 Sally Chang: Thank you, Olivier. That was A LOT of material 104 01:07:46 Eamon Caddigan: Thanks Olivier! 105 01:07:54 tataphani: Replying to "I never understood t..." 106 107 end 108 01:07:55 Jacob Schwan: Thanks Olivier! 109 01:07:58 Olivier: end 110 01:08:02 Retselisitsoe Monyake: Thank you 111 ``` 112 </details>