pad {gsignal} | R Documentation |
Pad data
Description
Pre- or postpad the data object x
with the value c
until it is
of length l
.
Usage
pad(x, l, c = 0, MARGIN = 2, direction = c("both", "pre", "post"))
prepad(x, l, c = 0, MARGIN = 2)
postpad(x, l, c = 0, MARGIN = 2)
Arguments
x |
Vector or matrix to be padded |
l |
Length of output data along the padding dimension. If |
c |
Value to be used for the padding (scalar). Must be of the same type
as the elements in |
MARGIN |
A vector giving the subscripts which the function will be
applied over. E.g., for a matrix 1 indicates rows, 2 indicates columns,
c(1, 2) indicates rows and columns. Where |
direction |
Where to pad the array along each dimension. One of the following:
|
Value
Padded data, returned as a vector or matrix.
Author(s)
Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.
Examples
v <- 1:24
res <- postpad(v, 30)
res <- postpad(v, 20)
res <- prepad(v, 30)
res <- prepad(v, 20)
m <- matrix(1:24, 4, 6)
res <- postpad(m, 8, 100)
res <- postpad(m, 8, 100, MARGIN = 1)
res <- prepad(m, 8, 100)
res <- prepad(m, 8, 100, MARGIN = 1)
res <- postpad(m, 2)
res <- postpad(m, 2, MARGIN = 1)
res <- prepad(m, 2)
res <- prepad(m, 2, MARGIN = 1)