I have a dataset that looks similar to this:
sex | observed | date | idtag |
---|---|---|---|
M | 0 | 10/20/2019 | 12 |
M | 0 | 10/20/2019 | 12 |
F | 0 | 10/20/2019 | 21 |
F | 0 | 10/20/2019 | 21 |
M | 0 | 10/21/2019 | 12 |
M | 1 | 10/21/2019 | 14 |
F | 0 | 10/21/2019 | 21 |
M | 1 | 10/21/2019 | 14 |
M | 1 | 10/21/2019 | 14 |
F | 1 | 10/21/2019 | 21 |
M | 0 | 10/23/2019 | 12 |
M | 0 | 10/23/2019 | 12 |
F | 0 | 10/23/2019 | 21 |
F | 0 | 10/23/2019 | 22 |
M | 0 | 10/23/2019 | 14 |
M | 1 | 10/23/2019 | 12 |
F | 0 | 10/23/2019 | 22 |
M | 1 | 10/23/2019 | 14 |
M | 1 | 10/23/2019 | 12 |
I would like to create a boxplot of detection rate by sex. I.e., I would like to compare (total number of observations by sex/number of 1s per sex). I used this code to calculate detection rate by sex:
drrate_sex <- detectiondata %>%
group_by(sex) %>%
summarise(dr = mean(observed))
This is the standard boxplot code I typically use:
boxplot(? ~ sex, data=drdata, main="Detection by sex",
xlab="Sex", ylab="Detection rate (%)", notch=T, par(mar=c(4,12,4,12)))
I am not sure how to incorporate detection rate (where I entered ? in the code) into the code to produce a boxplot in r that compares detection rate of females versus males. Any help would be appreciated.