I am trying to represent graphically the Median catching time (MCT) of mosquito that we have collected. The MCT represents the time for which 50% of the total malaria vectors were caught on humans. For example, we collected this sample:
Hour of collection / Mosquitoes number:
20H-21H = 1
21H-22H = 1
22H-23H = 2
23H-00H = 2
00H-01H = 13
01H-02H = 10
02H-03H = 15
03H-04H = 15
04H-05H = 8
05H-06H = 10
06H-07H = 6
Here the cumulated effective is 83 mosquitoes. And I am assuming that the median of this mosquito series is (83+1)/2 = 42, inducing a Median catching time at 2 am (02H-03H).
I tried to use the function "boxplot" with different parameters, but I cannot represent what I want. Indeed, I have boxes for each hour of collection when I want the representation of the cumulated effective over the collection time. Where the time range used are "20H-21H" = 20, "21H-22H" = 21 etc.
I found an article (Nicolas Moiroux, 2012) which represents graphically the MCT as intended. I copy the image of the cited boxplot here: Boxplot_Moiroux2012
Thank you in advance for your help.
Kind Regards.
PS, here is the code I used so far (with "Eff" = Number of mosquito and "Heure" = time of collection):
sum(Eff)
as.factor(Heure)
tapply(Eff,Heure,median)
tapply(Heure,Eff,median)
boxplot(Eff,horizontal=T)
boxplot(Heure~Eff)
boxplot(Eff~Heur))
You need to use a trick since you already have counts and not the time data for each catch.
First, you convert your time values to a more continuous variable, then you generate a vector with all the time values and then you boxplot (with a custom axis).
txt <- "20H-21H = 1
21H-22H = 1
22H-23H = 2
23H-00H = 2
00H-01H = 13
01H-02H = 10
02H-03H = 15
03H-04H = 15
04H-05H = 8
05H-06H = 10
06H-07H = 6"
dat <- read.table(text = txt, sep = "=", h = F)
colnames(dat) <- c("collect_time", "nb_mosquito")
# make a continuous numerical proxy for time
dat$collect_time_num <- 1:nrow(dat)
# get values of proxy according to your data
tvals <- rep(dat$collect_time_num, dat$nb_mosquito)
# plot
boxplot(tvals, horizontal = T, xaxt = "n")
axis(1, labels = as.character(dat$collect_time), at = dat$collect_time_num)
outputs the following plot :