x <- 1:10
y <- 5:14
z <- 16:25
a <- -1:-5
b <- -1
nearest_lgl(x, y)
nearest_lgl(y, x)
nearest_lgl(x, z)
nearest_lgl(z, x)
nearest_lgl(x, a)
nearest_lgl(a, x)
nearest_lgl(x, b)
nearest_lgl(b, x)
library(dplyr)
heights_near_min <- heights %>%
filter(nearest_lgl(min(height_cm), height_cm))
heights_near_fivenum <- heights %>%
filter(nearest_lgl(fivenum(height_cm), height_cm))
heights_near_qt_1 <- heights %>%
filter(nearest_qt_lgl(height_cm, c(0.5)))
heights_near_qt_3 <- heights %>%
filter(nearest_qt_lgl(height_cm, c(0.1, 0.5, 0.9)))
Run the code above in your browser using DataLab