average.parallel.helper: Average Parallel Helper

Description Usage Arguments Examples

View source: R/average.parallel.helper.R

Description

Average Parallel Helper

Usage

1
average.parallel.helper(break.pair, inttimes, data, start.time, interval)

Arguments

break.pair
inttimes
data
start.time
interval

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (break.pair, inttimes, data, start.time, interval) 
{
    ll <- break.pair[1]
    ul <- break.pair[2]
    avg.new <- as.data.frame(array(NA, dim = c(ul - ll + 1, ncol(data)), 
        dimnames = list(as.character(ll:ul), names(data))))
    for (i in ll:ul) {
        begin <- start.time + (i - 1) * interval
        end <- start.time + i * interval
        rows <- which(inttimes >= begin & inttimes < end)
        avg.new[as.character(i), 1] <- as.POSIXct(begin, origin = "1970-01-01", 
            tz = "PST")
        avg.new[as.character(i), 2:ncol(data)] <- apply(data[rows, 
            2:(ncol(data))], MARGIN = 2, FUN = mean, na.rm = T)
    }
    return(avg.new)
  }

colinsheppard/colinmisc documentation built on July 10, 2020, 5:59 p.m.