A collection of functions I've written while answering questions on Stack Overflow.

Details

Package:SOfun
Type:Package
Version:1.76
Date:2020-06-19
License:CC0

Author

Ananda Mahto

Maintainer: ananda@mahto.info Ananda Mahto

Examples

adjCombos(letters[1:5])
#> [[1]] #> [1] "a" "b" #> #> [[2]] #> [1] "b" "c" #> #> [[3]] #> [1] "c" "d" #> #> [[4]] #> [1] "d" "e" #> #> [[5]] #> [1] "a" "b" "c" #> #> [[6]] #> [1] "b" "c" "d" #> #> [[7]] #> [1] "c" "d" "e" #> #> [[8]] #> [1] "a" "b" "c" "d" #> #> [[9]] #> [1] "b" "c" "d" "e" #>
cvA <- c(12, 8, 11, 9); cvB <- c(NA, 7, NA, 10) completeVecs(cvA, cvB)
#> cvA cvB #> [1,] 8 7 #> [2,] 9 10
fx <- c("Y", "Y", "Yes", "N", "No", "H") Factor(fx, list(Yes = c("Yes", "Y"), No = c("No", "N")))
#> Input values: #> [1] "Y" "Y" "Yes" "N" "No" "H" #> #> Factored output: #> [1] Yes Yes Yes No No <NA> #> Levels: Yes No
moveA <- letters[1:10] moveMe(moveA, "a last; b, e, g before d; c first; h after j")
#> [1] "c" "b" "e" "g" "d" "f" "i" "j" "h" "a"
letterRep(20:40)
#> [1] "t" "u" "v" "w" "x" "y" "z" "aa" "bb" "cc" "dd" "ee" "ff" "gg" "hh" #> [16] "ii" "jj" "kk" "ll" "mm" "nn"
Riffle(1:6, "x")
#> [1] "1" "x" "2" "x" "3" "x" "4" "x" "5" "x" "6" "x"
Riffle(1:6, c("x", "y"))
#> [1] "1" "x" "2" "y" "3" "x" "4" "y" "5" "x" "6" "y"
set.seed(1) SampleToSum()
#> Total = 101
#> [1] 20 6 11 20 6 3 24 1 4 6
shiftX <- c(1, 4, 5, 2, 3, 6, 7, 8, 10, 9) shifter()[shiftX]
#> [1] 2 5 6 3 4 7 8 9 1 10
shuffler(letters[1:10])
#> [1] "i" "e" "j" "a" "g" "h" "f" "b" "c" "d"