I have a dataframe that looks like following:
df <- data.frame(site=paste0('site', sort(rep(1:5, 20))),
date=as.Date(paste0(sample(1:28, 100, replace=T), '/',
sample(1:12, 100, replace=T), '/',
2013),
'%d/%m/%Y'),
count=rep(seq(1, 1000, length.out=20), 10))
For each site, I need the earliest date in time count
> 500. In in other words, the first date at which the count was >50% of max count.