rep(x, n) or rep(x, repFac), where x is REAL, LOGICAL, or CHARACTER, and n is an integer > 0 or repFac is a vector of integers >= 0 |

rep(X, n), where n is a positive integer, replicates the values in X n times to form a vector of length n*length(X). It is equivalent to vector(X,X,X,...,X), where there are n repetitions of X. X must be a REAL, LOGICAL or CHARACTER vector, matrix, or array. rep(X, 0) is legal an has value NULL. rep(X, Repfac), where Repfac is a vector of integers with length(Repfac) = length(X) and Repfac[i] >= 0, replicates the j-th element of vector(X) Repfac[j] times. The result has length length(X)*sum(Repfac). If every element of Repfac is 0, the result is NULL. Examples: Cmd> rep(vector(1,3,5),4) # returns vector(1,3,5,1,3,5,1,3,5,1,3,5) Cmd> rep(vector(7,6,5),vector(3,0,2)) # returns vector(7,7,7,5,5) Cmd> a <- factor(rep(run(4),5)); b <- factor(rep(run(5),rep(4,5))) computes factors suitable for a 4 by 5 design with no replications. Cmd> rep(run(5), vector(1,2,3))# ERROR! (args have different lengths) WARNING: Because rep() is a function you cannot use the name 'rep' as a variable name, say for a replication factor in a design. Use 'Rep' or 'reps' instead. See also topics vector(), run(), 'models', 'glm'.

Gary Oehlert 2003-01-15