R/Cumulative Animal Counting.R

Defines functions CumulativeAnimals

CumulativeAnimals<-function(df,unit){
  
  df2<-data.frame(Unit=min(df[,unit],na.rm=T):max(df[,unit],na.rm=T),
                  Count=sapply(min(df[,unit],na.rm=T):max(df[,unit],na.rm=T),
         function(l) length(unique(df[df[,unit]<=l,"Animal"]))
  ))
  
  names(df2)[1]<-unit
  return(df2)
}
gfalbery/ggregplot documentation built on Feb. 4, 2025, 3:17 a.m.