Learn R Programming

gRapHD (version 0.2.5)

rowProds: Row products

Description

Form row products for numeric arrays.

Usage

rowProds(x,na.rm=TRUE)

Arguments

x

matrix.

na.rm

logical. Whether missing values (including NaN) are omitted from the calculations.

Value

Vector with length nrow(x).

Details

Equivalent to use of apply with FUN = prod and MARGIN = 1, but is faster.

Examples

Run this code
# NOT RUN {
set.seed(1,kind="Mersenne-Twister")
a <- matrix(rnorm(100),nrow=5)
x <- rowProds(x=a, na.rm=TRUE)
# x
# [1] -3.359208e-07 -2.861043e-10 -2.831108e-08 
# [4] -5.451996e-07  3.057436e-04
# }

Run the code above in your browser using DataLab