Meeting chat log
00:24:22 Jon Harmon (jonthegeek): Famous computer science quote: There are only two hard things in Computer Science: cache invalidation and naming things.
-- Phil Karlton
00:32:31 Jon Harmon (jonthegeek): > identical(1.0, 1L)
[1] FALSE
00:32:50 Jon Harmon (jonthegeek): > 1.0 == 1L
[1] TRUE
00:33:31 Jon Harmon (jonthegeek): identical(as.integer(1.0), 1L)
00:33:49 Jon Harmon (jonthegeek): identical(1.0, as.double(1L))
00:38:39 Njoki Njuki Lucy: is there a difference between ifelse() and if, else function?
00:39:32 Jon Harmon (jonthegeek): ifelse()
if … else if … else
00:40:15 Jon Harmon (jonthegeek): ifelse(c(TRUE, FALSE, TRUE), "yes", "no")
00:40:28 Jon Harmon (jonthegeek): > ifelse(c(TRUE, FALSE, TRUE), "yes", "no")
[1] "yes" "no" "yes"
00:40:52 Jon Harmon (jonthegeek): > ifelse(1:10 == 8, "it's 8", "it isn't")
[1] "it isn't" "it isn't" "it isn't" "it isn't" "it isn't" "it isn't" "it isn't"
[8] "it's 8" "it isn't" "it isn't"
00:41:12 Jon Harmon (jonthegeek): > ifelse(1:10 == 8, 8, NA)
[1] NA NA NA NA NA NA NA 8 NA NA
00:42:13 Ryan Metcalf: Possible Reference, Section 7.4, Missing Values. It makes a reference to `ifelse()` function: https://r4ds.had.co.nz/exploratory-data-analysis.html?q=ifelse()#missing-values-2
00:43:01 Jon Harmon (jonthegeek): if else
ifelse
if_else
00:43:17 Njoki Njuki Lucy: thank you!
00:43:22 Njoki Njuki Lucy: big time:)
00:50:35 Njoki Njuki Lucy: what exactly is the trim doing? I didn't understand
00:52:05 Jon Harmon (jonthegeek): > mean(c(1, 90:100), trim = 0)
[1] 87.16667
> mean(c(1, 90:100), trim = 0.1)
[1] 94.5
> mean(c(1, 90:100), trim = 0.5)
[1] 94.5
00:52:46 Jon Harmon (jonthegeek): > mean(1:10, trim = 0.5)
[1] 5.5
00:54:10 Njoki Njuki Lucy: okay, understood. thanks!
00:58:15 Jon Harmon (jonthegeek): myfun <- function(x, ...) {
mean(x, ...)
}
00:58:47 Jon Harmon (jonthegeek): > myfun(1:10, trim = 0.1)
[1] 5.5
00:59:13 Jon Harmon (jonthegeek): > myfun(1:10, trim = 0.1)
Error in myfun(1:10, trim = 0.1) : unused argument (trim = 0.1)
01:01:34 Jon Harmon (jonthegeek): myfun <- function(x, funname, ...) {
if (funname == "mean") {
mean(x, ...)
} else {
log(x, ...)
}
}
01:04:11 Jon Harmon (jonthegeek): myfun <- function(...) {
dots <- list(...)
names(dots)
}
myfun(a = 1)
01:05:28 Jon Harmon (jonthegeek): [1] "a"
01:05:49 Jon Harmon (jonthegeek): dots <- list(a = 1)
01:09:32 Jon Harmon (jonthegeek): myfun <- function(a, b) {
a
}
myfun(1:10, Sys.sleep(60))