Learn R Programming

multivariance (version 2.4.1)

sample.cols: resample the columns of a matrix

Description

resample the columns of a matrix

Usage

sample.cols(x, vec = 1:ncol(x), replace = TRUE, incl.first = TRUE)

Arguments

x

matrix

vec

vector, indicates which columns belong together

replace

boolean, sampling with or without replacement

incl.first

boolean, if TRUE also the first component is resampled

Value

Returns a matrix with the same dimensions as x. The columns are resampled from the original columns. The resampling is done with replacement (replace = TRUE) or without (replace = FALSE). Columns which belong together (indicated by vec) are resampled identically, i.e., all values in rows of these are kept together.

Examples

Run this code
# NOT RUN {
sample.cols(matrix(1:15,nrow = 5),vec = c(1,1,2))

# }

Run the code above in your browser using DataLab