Learn R Programming

gRbase (version 1.7-5)

gRbase-utilities: Utility functions for gRbase

Description

Utility functions for gRbase package. Includes 'faster versions' of certain standard R functions.

Arguments

Value

A vector or a logical.

Details

colwiseProd multiplies a vector and a matrix columnwise (as opposed to rowwise which is achieved by v*M). Hence colwiseProd does the same as t(v*t(M)) - but it does so faster for numeric values.

Examples

Run this code

## colwiseProd
M <- matrix(1:16, nrow=4)
v <- 1:4

t(v*t(M))
colwiseProd(v,M)

system.time(for (ii in 1:100000)  t(v*t(M)))
system.time(for (ii in 1:100000)  colwiseProd(v,M))

Run the code above in your browser using DataLab