Lab Exercise for R: Combinatorics

Exercise 1 Combinations:

> choose (5,2)
> binom.test(10, 12, 0.5, alternative="two.sided")
> pascalTri <- function(h) { lapply(0:h, function(i) choose(i, 0:i)) }
> pascalTri(5)

Exercise 2 Permutations:

> install.packages('gtools')
> library(gtools)
> balls <- c('red', 'blue', 'black')
> permutations(n=3,r=2,v=balls)
> bags <- c('green', 'red', 'blue', 'black')
> permutations(n=4, r=3, v=bags, repeats.allowed=T)




last modified: 1/27/17