###--- >>> `chisq.test' <<<----- Pearson's Chi-squared Test for Count Data

	## alias	 help(chisq.test)

##___ Examples ___:

data(InsectSprays)              # Not really a good example
chisq.test(InsectSprays$count > 7, InsectSprays$spray)
                                # Prints test summary
chisq.test(InsectSprays$count > 7, InsectSprays$spray)$obs
                                # Counts observed
chisq.test(InsectSprays$count > 7, InsectSprays$spray)$exp
                                # Counts expected under the null

## Effect of simulating p-values
x <- matrix(c(12, 5, 7, 7), nc = 2)
chisq.test(x)$p.value           # 0.4233
chisq.test(x, simulate.p.value = TRUE, B = 10000)$p.value
                                # around 0.29!

## Testing for population probabilities
## Case A. Tabulated data
x <- c(A = 20, B = 15, C = 25)
chisq.test(x)
chisq.test(as.table(x))         # the same
## Case B. Raw data
x <- trunc(5 * runif(100))
chisq.test(table(x))            # NOT `chisq.test(x)'!

## Keywords: 'htest', 'distribution'.


