add R functions for permutations and C function for combination