Commit e3f03506 authored by Laura Mack's avatar Laura Mack
Browse files

change in using fastmatch

parent 2f68e6d0
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#' @export #' @export
#' @importFrom pbapply pbsapply #' @importFrom pbapply pbsapply
#' @importFrom RcppRoll roll_sum #' @importFrom RcppRoll roll_sum
#' @importFrom fastmatch ctapply
#' #'
#' @examples #' @examples
#' dates <- as.Date("2019-01-01")+0:729 #' dates <- as.Date("2019-01-01")+0:729
...@@ -74,7 +75,7 @@ ...@@ -74,7 +75,7 @@
runsum <- runsum/ds #intensity per hour runsum <- runsum/ds #intensity per hour
max.subset <- lapply(1:length(which.mon),function(m.i){ max.subset <- lapply(1:length(which.mon),function(m.i){
subset <- is.element(as.POSIXlt(data.s[,names[1]])$mon,which.mon[[m.i]]) subset <- is.element(as.POSIXlt(data.s[,names[1]])$mon,which.mon[[m.i]])
max <- tapply(runsum[subset],(as.POSIXlt(data.s[,names[1]])$year+1900)[subset], max <- ctapply(runsum[subset],(as.POSIXlt(data.s[,names[1]])$year+1900)[subset],
function(vec){ function(vec){
n.na <- sum(is.na(vec)) n.na <- sum(is.na(vec))
max <- ifelse(n.na <= na.accept*length(vec),max(vec,na.rm = TRUE),NA) max <- ifelse(n.na <= na.accept*length(vec),max(vec,na.rm = TRUE),NA)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment