I hereby claim:
- I am claytonjy on github.
- I am claytonjy (https://keybase.io/claytonjy) on keybase.
- I have a public key ASAaodN6sNLW7mO0wHrRnhOVEUExdgEY99aJVvwWrZCiWAo
To claim this, I am signing this object:
# x is assumed to be a numeric vector | |
# output will be TRUE if both that value and the previous value are strictly below the threshold, FALSE otherwise | |
f <- function(x, threshold) { | |
less_than <- (x < threshold) | |
less_than & c(FALSE, !diff(less_than)) | |
} | |
#### usage #### |
I hereby claim:
To claim this, I am signing this object:
library(rlang)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
# test function | |
f <- function(x) { | |
if (missing(x)) { | |
stop("error, Will Robinson") | |
} else { | |
x | |
} | |
} | |
f(1) # 1 |
library(dplyr) | |
library(purrr) | |
library(rsample) | |
# suppose we want to keep cylinder-groups together | |
# we'll vfold those instead of the whole thing | |
initial_fold <- mtcars %>% | |
distinct(cyl) %>% | |
vfold_cv(v = 3) |
diag(1.1)
#> [,1]
#> [1,] 1
diag(0.9)
#> <0 x 0 matrix>
diag(0.9, nrow = 1)
#> [,1]
#> [1,] 0.9
diag(-1)
library(dplyr) | |
library(purrr) | |
#### setup #### | |
tbl <- tibble( | |
id = 1:25 | |
) |
library(dplyr) | |
library(purrr) | |
# helper to make examples | |
new_tbl <- function(n_groups, row_range = 5:10) { | |
1:n_groups %>% | |
map_df(~tibble( | |
group_id = .x, | |
value = rnorm(sample.int(row_range, 1L)) |
library(tidyverse) | |
mt_tbl <- as_tibble(mtcars) | |
# types need to match those in mtcars (all doubles) | |
# careful; `na_if` doesn't work with multiple values | |
missing_codes <- list( | |
cyl = 6.0, | |
disp = 160.0, | |
carb = 1.0 |
library(ggplot2) | |
library(rlang) | |
f <- function(df, x, y, facet) { | |
x <- enquo(x) | |
y <- enquo(y) | |
facet = enquo(facet) | |
g <- ggplot(df, aes(x = !!x, y = !!y)) + |