Replicate Data Values

DESCRIPTION:
Replicates the input either a certain number of times or to a certain length.

USAGE:
rep(x, times = <<see below>>, length.out = <<see below>>)

REQUIRED ARGUMENTS:
x:
vector. Missing values (NAs) are allowed.

At least one of times and length.out must be given.


OPTIONAL ARGUMENTS:
times:
how many times to replicate x. There are two ways to use times. If it is a single value, the whole of x is replicated that many times. If it is a vector that is the same length as x, the result is a vector with times[1] replications of x[1], times[2] of x[2], etc. Zero is allowed in both usages; if times=0, then the length of the result is 0. It is an error if the length of times is neither 1 nor the length of x.
length.out:
the desired length of the result. This argument may be given instead of times, in which case x is replicated as much as needed to produce a result with length.out data values. If both times and length.out are given, times is ignored.

VALUE:
a vector of the same mode as x with the data values in x replicated according to the argument times or length.out.

DETAILS:
Missing values (NAs) and Infs are treated just like other values.

SEE ALSO:
c , unique .

EXAMPLES:
rep(0, 100)    # 100 zeros

# 1, 2, 3, 4 repeated until there are 48 numbers rep(1:4, length.out = 48)

rep(1:10, 10) # 10 repetitions of 1:10 rep(1:10, 1:10) # 1, 2, 2, 3, 3, 3, ...