blocksel: Block selection in a matrix

View source: R/blocksel.R

blockselR Documentation

Block selection in a matrix

Description

Function blocksel selects blocks (i.e. sets of columns) within a given matrix and concatenates the selected blocks into a new matrix.

Usage


blocksel(X, blocks)

Arguments

X

A n x p matrix or data frame of variables.

blocks

A list of same length as the number of blocks. Each component of the list gives the column numbers in X defining the given block.

Value

X

A matrix with the concatenated blocks.

blocks

A list of column numbers defining the blocks in the output matrix X.

Examples


n <- 3 ; p <- 10
set.seed(1)
X <- matrix(rnorm(n * p, mean = 10), ncol = p, byrow = TRUE)
colnames(X) <- paste("Var", 1:p, sep = "")
set.seed(NULL)
X

blocks <- list(1:2, 4, 6:8)
blocks

blocksel(X, blocks) 


mlesnoff/rnirs documentation built on April 24, 2023, 4:17 a.m.