-1

I am writing to your forum because I do not find solution for my problem. I am trying to represent graphically the Median catching time (MCT) of mosquito that we (my team and I) have collected (I am currently in an internship to study the malaria in Ivory Coast). 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 effective cumulated is 83 mosquitoes. And I am assuming that the median of this mosquito serie is 83+1/2 = 42 (And I don't even find this number on R), inducing a Median catching time at 2 am (02).

Therefore, I have tried to use the function "boxplot" with different parameters, but I cannot have what I want to represent. Indeed, I have boxes for each hour of collection when I want the representation of the effective cumulated over the time of collection. And the time use in R is "20H-21H" = 20, "21H-22H" = 21 etc.

I have found an article (Nicolas Moiroux, 2012) who presents the Median Catching Time and a boxplot that I should like to have. I copy the image of the cited boxplot: Boxplot_Moiroux2012

Thank you in advance for your help, and I hope that my grammar is fine (I speak and write mainly in French, my mother tongue).

Kind Regards, Edouard

PS : And regarding the code I have used with this set of data, here I am (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))

(My skills on R are not very sharp...)

RoB
  • 1,833
  • 11
  • 23
mikyscott
  • 3
  • 3
  • Can you also provide the R code of what you have done so far? – geoidiot Feb 27 '20 at 15:45
  • That's not how the median is defined... (even `(83 + 1) / 2` will still not give you the median) – dario Feb 27 '20 at 15:52
  • 1
    Hi Edouard94. Welcome to StackOverflow! Please read the info about [how to ask a good question](https://stackoverflow.com/help/how-to-ask) and how to give a [minimale reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610). That way you can help others to help you! – dario Feb 27 '20 at 15:53
  • @dario He wants the median catching time, for this selecting the 42nd mosquito and taking it's time is correct. But the 42nd mosquito was caught at 3 am – geoidiot Feb 27 '20 at 16:01
  • Hello, thanks for your comments. @geoidiot, that is correct, the 42nd mosquito was caught between 2am and 3am (if I am not wrong). So I consider it is the first hour of the time range ie 2am (02). – mikyscott Feb 27 '20 at 16:08

1 Answers1

1

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 :

enter image description here

RoB
  • 1,833
  • 11
  • 23
  • hello @RoB, thank you a lot for your answer that will help me to analyse my other data. Thank you to share your knowledge and skills, it is very valuable – mikyscott Feb 27 '20 at 16:28