What test can I use to compare count data across groups? I've conducted an experiment using seeds from several locations to test their viability. For each location, seeds were classed as viable or non-viable, giving me the total amount of viable and non-viable seeds for each location as my dataset. Now I would like to compare the locations to see if there is any significant difference in the viability between them, but I am getting stuck on which test or model (eg binomial model, glm etc) to use and how I might plot these results. Any help would be appreciated!




location
viable
non-viable




1
55
35


2
66
24


3
67
23


4
59
31


5
37
53




(We typically use the name "count data" to refer to non-negative whole numbers without a known upper bound. These are counts in some sense, but of which of two categories a known total number of seeds falls into.)
If you have no covariates, etc., you can test these with a chi-squared test.  You could make a plot, but these are straightforward enough that I think a table of row-wise proportions would be sufficient to communicate this to others.  Here is an example, coded in R:
d = read.table(text="location     viable    non-viable
  1     55  35
  ...
  5     37  53", header=TRUE)
tab = as.table(as.matrix(d[,2:3]))
round(prop.table(tab, margin=1), digits=3)
#   viable non.viable
# A  0.611      0.389
# B  0.733      0.267
# C  0.744      0.256
# D  0.656      0.344
# E  0.411      0.589
chisq.test(tab)
# 
#   Pearson's Chi-squared test
# 
# data:  tab
# X-squared = 28.101, df = 4, p-value = 1.19e-05

