sumAlong: sumAlong

Description Usage Arguments Details Examples

View source: R/sumAlong.R

Description

Sum along a chosen dimension of an arbitrarily dimensioned array.

Usage

1
  sumAlong <- function(x, along)

Arguments

x

An n dimensional array

along

the dimension of x to sum along

Details

# The method of the source code came from Hadley Wickham: # https://stackoverflow.com/questions/14500707/select-along-one-of-n-dimensions-in-array

This function returns an n - 1 dimensional array that is the result of summing along the along dimension.

Examples

1
2
3
4
5
6
7
  nx = 3
  ny = 3
  nz = 3
  x = array(1:(nx*ny*nz), dim = c(nx, ny, nz))

  print(x)
  sumAlong(x, 3)

dcbdan/s525 documentation built on May 19, 2019, 10:48 p.m.