Use replicate
. For example:
(x <- replicate(3,rgeom(10,50/239)))
[,1] [,2] [,3]
[1,] 5 3 12
[2,] 15 2 3
[3,] 5 5 0
[4,] 4 2 1
[5,] 13 0 8
[6,] 0 3 0
[7,] 3 1 6
[8,] 0 6 2
[9,] 0 4 4
[10,] 8 4 1
You can test on them using apply
apply(x,2,chisq.test)
[[1]]
Chi-squared test for given probabilities
data: newX[, i]
X-squared = 47.566, df = 9, p-value = 3.078e-07
[[2]]
Chi-squared test for given probabilities
data: newX[, i]
X-squared = 10, df = 9, p-value = 0.3505
[[3]]
Chi-squared test for given probabilities
data: newX[, i]
X-squared = 37.3243, df = 9, p-value = 2.303e-05
Warning messages:
1: In FUN(newX[, i], ...) : Chi-squared approximation may be incorrect
2: In FUN(newX[, i], ...) : Chi-squared approximation may be incorrect