Apply.Rd 1.57 KB
Newer Older
Alasdair Hunter's avatar
Alasdair Hunter committed
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Apply.R
\name{Apply}
\alias{Apply}
\title{Wrapper For Applying Atomic Functions To Arrays.}
\usage{
Alasdair Hunter's avatar
Alasdair Hunter committed
Apply(data, margins = NULL, AtomicFun, ..., parallel = FALSE,
  ncores = NULL)
Alasdair Hunter's avatar
Alasdair Hunter committed
}
\arguments{
\item{data}{A single object (vector, matrix or array) or a list of objects.}

Alasdair Hunter's avatar
Alasdair Hunter committed
\item{margins}{List of vectors containing the margins for the function to be applied over for each object in the data. Or, if there is a single vector of margins specified and a list of objects in data, then the single set of margins is applied over all objects.}
Alasdair Hunter's avatar
Alasdair Hunter committed

\item{AtomicFun}{Function to be applied to the arrays.}

\item{...}{Additional arguments to be used in the AtomicFun.}

\item{parallel}{Logical, should the function be applied in parallel.}

\item{ncores}{The number of cores to use for parallel computation.}

}
\value{
Array with dimensions equal to margins[[1]], and any additional dimensions resulting from AtomicFun.
}
\description{
A wrapper for applying a function across one or more arrays. The user can input one or more arrays, and specify the dimensions of each the arrays over which the function should be looped. This is a extension of the apply paradigm to the case where the data being considered is distributed across multiple objects.
}
\examples{
data = list(array(rnorm(1000), c(10,10,10)),array(rnorm(1000), c(10,10,10)))
margins = list(c(1, 3), c(1, 3))
corr <- Apply(data, margins, AtomicFun = "cor")
}
\references{
Wickham, H (2011), The Split-Apply-Combine Strategy for Data Analysis, Journal of Statistical Software.
}