Description Usage Arguments Examples
View source: R/average.parallel.helper.R
Average Parallel Helper
1 | average.parallel.helper(break.pair, inttimes, data, start.time, interval)
|
break.pair |
|
inttimes |
|
data |
|
start.time |
|
interval |
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)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.