sort_uniq
Here are a few functions that I am creating as shorthands for some of commonly used expressions/combined functions I keep coming back to. The idea is to read this package and its functions into any random project I’m working on so I can have these shorthands, handy (even if they don’t seem very R-like).
vec <- sample(1:10, size = 20, replace=TRUE)
vec
#> [1] 7 5 6 4 6 9 5 5 8 2 7 5 5 2 6 4 2 3 9 6
sort_uniq(vec)
#> [1] 2 3 4 5 6 7 8 9
A funny thing I ended up realizing when trying to write a “simple test”:
There’s a tiny probability that this could fail randomly and it wouldn’t even be wrong! So the lesson here is don’t write tests like mine.