# Compare proportion of value between groups in R

I have 4 groups in which I have for each 7 days

    Days  G1    G2  G3  G4
Day1  85    16  32  92
Day2  23    9   11  33
Day3  41    2   21  27
Day4  19    6   6   15
Day5  6     1   3   7
Day6  28    5   2   6
Day7  66    11  15  27


And I would like to compare each group by the proportion of values depending on the days.

Is there any statistic test I can use in order to test for instance that the proportion of values distributed on the 7 days is not statistically different between G1 and G2?

Here is the data in dput format:

structure(list(days = c("Day1", "Day2", "Day3", "Day4", "Day5",
"Day6", "Day7"), G1 = c(85L, 23L, 41L, 19L, 6L, 28L, 66L),
G2 = c(16L, 9L, 2L, 6L, 1L, 5L, 11L),
G3 = c(32L, 11L, 21L, 6L, 3L, 2L, 15L),
G4 = c(92L, 33L, 27L, 15L, 7L, 6L, 27L)),
class = "data.frame", row.names = c(NA, -7L))

• Are the numbers counts? Commented Mar 27, 2023 at 12:12
• yes, I thought to use a chisq.test but some value are < 5... Commented Mar 27, 2023 at 12:22
• assuming measurements on different days are independent, you could use a Poisson test. Commented Mar 27, 2023 at 12:25
• The assumption of > 5 is about the expected values, not the values themselves. Commented Mar 27, 2023 at 16:16

## 1 Answer

You could start with some visualization:

R code for the plot:

#  Assign data frame in question to variable dat, then
dat0 <- reshape2::melt(dat,id.vars=1, measure.vars=2:5, variable.name="Group",
value.name="Count")
library(ggplot2)
dat0 |> ggplot(aes(days, Count, color=Group, group=Group)) +  geom_point() + geom_line()