reduce_along: Reduction of x along a specific dimension

Description Usage Arguments Details Value Examples

Description

mapnd() and reduce_dim() is not true map-reduce since mapnd() does not emit anything. However, these functions are designed to mimic the map-reduce paradigm in hope of facilitating a uniform data processing scheme for all objects.

Usage

1
2
3
reduce_along(x, along, reduce_func = NULL, names = NULL, ...)

reduce_lastdim(x, reduce_func = NULL, names = NULL, ...)

Arguments

x

data to reduce.

along

axis/dimension to reduce.

reduce_func

a function to perform the reduction.

names

set names to results.

...

passed to reduce_func.

Details

reduce_lastdim() reduces x along last dimension, and it is a bit more efficient since no permutation is done to x.

Value

a list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
max_avg_current <- function(abf) {
  abf %>%
     samplend(ratio = 1000, func = "mean") %>%
     reduce_lastdim(reduce_func = max)
}

plot_iv <- function(abf, intv) {
  p <- abf[MaskIntv(intv),,] %>%
          mapnd(func = "mean") %>%
          reduce_lastdim(names = c("current", "voltage")) %>%
          data.frame() %>%
          ggplot(mapping = aes_string("current", "voltage"))
  p + geom_line()
}

## End(Not run)

Crystal-YWu/abftools documentation built on May 10, 2019, 8:22 a.m.