Learn R Programming

Boom (version 0.8)

thin.matrix: Thin a Matrix

Description

Return discard all but every k'th row of a matrix.

Usage

ThinMatrix(mat, thin)

Arguments

mat

The matrix to be thinned.

thin

The distance between kepts lines from mat. The larger the number the fewer lines are kept.

Value

The matrix mat, after discarding all but every thin lines.

Details

The bigger the value of thin the more thinning that gets done. For example, thin = 10 will keep every 10 lines from mat.

Examples

Run this code
# NOT RUN {
m <- matrix(1:100, ncol = 2)
ThinMatrix(m, thin = 10)
##      [,1] [,2]
## [1,]   10   60
## [2,]   20   70
## [3,]   30   80
## [4,]   40   90
## [5,]   50  100
# }

Run the code above in your browser using DataLab