rowCopy: Copy a vector into a matrix

Description Usage Arguments Details Value Warning Author(s) See Also Examples

Description

Creates a matrix by binding multiple copies of a vector together, either by row or by column

Usage

1
2
	colCopy(x,times, dimnames=NULL )
	rowCopy(x,times, dimnames=NULL )

Arguments

x

The vector to be copied

times

Number of copies of the vector to bind together

dimnames

List specifying row and column names

Details

This is a convenience function for binding together multiple copies of the same vector. The intended usage is for situations where one might ordinarily use rbind or cbind, but the work is done by the matrix function. Instead of needing to input multiple copies of the input vector x (as one would for rbind), one only needs to specify the number of times that the vector should be copied.

Value

For rowCopy, the output is a matrix with times rows and length(x) columns, in which each row contains the vector x. For colCopy, each column corresponds to the vector x.

Warning

This package is under development, and has been released only due to teaching constraints. Until this notice disappears from the help files, you should assume that everything in the package is subject to change. Backwards compatibility is NOT guaranteed. Functions may be deleted in future versions and new syntax may be inconsistent with earlier versions. For the moment at least, this package should be treated with extreme caution.

Author(s)

Daniel Navarro

See Also

matrix, rbind, replicate

Examples

1
2
3
4
5
6
7
8
#### Example 1: basic usage 
data <- c(3,1,4,1,5)
rowCopy( data, 4 ) 
colCopy( data, 4 )

#### Example 2: attach dimension names
dnames <- list( rows = c("r1","r2","r3"), cols = c("c1","c2","c3","c4","c5") )
rowCopy( data,3,dnames )

lsr documentation built on May 2, 2019, 2:51 p.m.