Skip to content

Instantly share code, notes, and snippets.

View ClaytonJY's full-sized avatar
🏂

Clayton Yochum ClaytonJY

🏂
View GitHub Profile
@ClaytonJY
ClaytonJY / tryCatch-example.R
Created September 6, 2017 16:11
tryCatch in R
# test function
f <- function(x) {
if (missing(x)) {
stop("error, Will Robinson")
} else {
x
}
}
f(1) # 1
@ClaytonJY
ClaytonJY / rlang-purrr-dplyr-issue.md
Last active August 2, 2017 20:03
tidyeval not behaving when used inside purrr and dplyr
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':
#> 
@ClaytonJY
ClaytonJY / keybase.md
Created May 24, 2017 20:05
Keybase Proof

Keybase proof

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:

@ClaytonJY
ClaytonJY / two-in-a-row-example.R
Created April 3, 2017 18:06
Two-in-a-row below a threshold
# 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 ####