Last active
January 17, 2017 04:06
-
-
Save wdkrnls/e08010d6ec2c30e9ba53f73f111a881b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# all.equal does a lot, nearly_equal does little. | |
nearly_equal <- function(x, y, tol = sqrt(.Machine$double.eps)) y < x + tol & y > x - tol | |
# syntax can be confusing to beginners | |
which_is <- function(x, test) x[which(test)] | |
x <- seq(0, 2*pi, by = 0.01) | |
library(magrittr) | |
x %>% which_is(nearly_equal(sin(x), 0.5, tol = 0.005)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment