randomMatrix: Create a Matrix with Random Integer Values

View source: R/matrix.R

randomMatrixR Documentation

Create a Matrix with Random Integer Values

Description

Create a matrix of given dimension and fill it with random integer values

Usage

randomMatrix(dim = c(sample(10, 1), sample(10, 1)), values = seq_len(100))

Arguments

dim

integer vector of length two containing the number of rows and columns, respectively, that the output matrix shall contain

values

set of values to be used within the matrix

Examples


# By default, the matrix has a random number of rows between 1 and 10 and
# a random number of columns between 1 and 10 and random values of 1:100
randomMatrix()

# You may specify the dimensions (here: 5 rows, 3 columns)...
randomMatrix(dim = c(5, 3))

# ... and the set of values to be used within the matrix
randomMatrix(dim = c(5, 3), values = c(0, 0.5, 1, NA))


KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.