Need help for chi test

Here are my codes. Do anyone to help me if I understand the chi test correctly.

library(tidyverse)
# twenty insect individuals were put into Y-type tube, and let them to chooose the plant (A or B) randomly. After 24 hours, the numbers of insect on plants were counted. The expriments were performed with sixteen repilicats. 
data <- tibble(Variety = rep("fly", 16), Rep = seq((1:16)), No_in_plant_A = c(14, 9, 12, 11, 9, 9, 14, 19, 12, 14, 10, 12, 9, 14, 8, 16), No_in_plant_B = c(6, 11, 8, 9, 11, 11, 6, 1, 8, 6, 10, 8, 11, 6, 12, 4))
# perfomore chi test for each variety if necessary,
data %>% 
  select(-Rep) %>% 
  group_nest(Variety) %>% 
  mutate(chi_res = map(data, rstatix::chisq_test, p = 0.5)) %>% 
  select(Variety, chi_res) %>% 
  unnest(chi_res)
#> # A tibble: 1 × 7
#>   Variety     n statistic      p    df method          p.signif
#>   <chr>   <dbl>     <dbl>  <dbl> <int> <chr>           <chr>   
#> 1 fly       320      28.8 0.0173    15 Chi-square test *

Created on 2024-01-04 with reprex v2.0.2

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.