I have the sex ratios (M / M + F)
of the offspring of ~35,000 mother birds from >400 species organized in this manner:
IOC_species | DamID | SR |
---|---|---|
Acanthis_flammea | 3579601 | 0.333333333 |
Accipiter_gentilis | 3431823 | 0.333333333 |
Accipiter_gentilis | 3109836 | 0.4 |
Accipiter_gentilis | 3824842 | 0.636363636 |
Accipiter_nisus | 542070 | 0.5 |
Accipiter_nisus | 4006664 | 0.5 |
Acridotheres_burmannicus | 2207112 | 1 |
Acridotheres_burmannicus | 947697 | 0.666666667 |
Acridotheres_burmannicus | 10101 | 0.833333333 |
Acridotheres_cristatellus | 920019 | 0.333333333 |
I want to calculate the median sex ratio per species and then use a statistic to see if this differs significantly from 50/50. My current plan is to use a one-sample sign test in the DescTools
package on R. Here is the code I've been using:
library(DescTools)
data <- read.csv(file.choose())
df <- data.frame(Species=data$IOC_species,SR=data$SR)
sumstats = df %>% group_by (Species) %>%
summarise (medianSR = median(SR), signtest = SignTest (SR,mu=.5),.groups='drop'))
When I do this I get the following error message:
Error in `summarise()`:
! Problem while computing `signtest = SignTest(SR, mu = 0.5), .groups =
"drop")`.
x `signtest` must be a vector, not a `htest` object.
i The error occurred in group 1: Species = "Acanthis_flammea".
Run `rlang::last_error()` to see where the error occurred.
I'm not sure where to go from here - as might be obvious I am fairly new to RStudio. Ideally, I want my answers formatted in a summary table with species names, medians, n's, and sign test p-values. Thanks in advance!