apply {dibble}R Documentation

Apply functions over array margins

Description

Applying a function to margins of a dibble or array, including a matrix.

Usage

apply(X, MARGIN, FUN, ...)

## Default S3 method:
apply(X, MARGIN, FUN, ..., simplify = TRUE)

## S3 method for class 'tbl_ddf'
apply(X, MARGIN, FUN, ...)

## S3 method for class 'ddf_col'
apply(X, MARGIN, FUN, ...)

Arguments

X

A dibble or array, including a matrix.

MARGIN

An integer or character vector giving the subscripts which the function will be applied over.

FUN

A function to be applied.

...

Optional arguments to FUN.

simplify

A logical indicating whether results should be simplified if possible.

Details

apply() overrides base::apply() to make it generic. The default method calls the base version.

Value

A dibble if X is a dibble. See base::apply() for the return value of the default method.

See Also

base::apply().

Examples

x <- array(1:24, 2:4,
           list(axis1 = letters[1:2],
                axis2 = letters[1:3],
                axis3 = letters[1:4]))

apply(x, 2:3, sum)
apply(as_dibble(x), 2:3, sum)

apply(x, c("axis2", "axis3"), sum)
apply(as_dibble(x), c("axis2", "axis3"), sum)


[Package dibble version 0.2.2 Index]