Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

wkeep

Keep part of vector or matrix


Description

Extract elements from a vector or matrix.

Usage

wkeep(x, l, opt = "centered")

Arguments

x

input data, specified as a numeric vector or matrix.

l

either a positive integer value, specifying the length to extract from the input *vector* x, or a vector of length 2, indicating the submatrix to extract from the *matrix* x. See the examples.

opt

One of:

character string

matched against c("centered", "left", "right"), indicating the location of the *vector* x to extract

positive integer

starting index of the input *vector* x

two-element vector

starting row and columns from the *matrix* x

See the examples. Default: "centered".

Value

extracted vector or matrix

Author(s)

Sylvain Pelissier, sylvain.pelissier@gmail.com.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

Examples

## create a vector
x <- 1:10
## Extract a vector of length 6 from the central part of x.
y <- wkeep(x, 6, 'c')

## Extract two vectors of length 6, one from the left part of x, and the
## other from the right part of x.
y <- wkeep(x, 6, 'l')
y <- wkeep(x, 6, 'r')

## Create a 5-by-5 matrix.
x <- matrix(round(runif(25, 0, 25)), 5, 5)

## Extract a 3-by-2 matrix from the center of x
y <- wkeep(x, c(3, 2))

## Extract from x the 2-by-4 submatrix starting at x[3, 1].
y <- wkeep(x, c(2, 4), c(3, 1))

gsignal

Signal Processing

v0.3-1
GPL-3
Authors
Geert van Boxtel [aut, cre] (Maintainer), Tom Short [aut] (Author of 'signal' package), Paul Kienzle [aut] (Majority of the original sources), Ben Abbott [ctb], Juan Aguado [ctb], Muthiah Annamalai [ctb], Leonardo Araujo [ctb], William Asquith [ctb], David Bateman [ctb], David Billinghurst [ctb], Juan Pablo Carbajal [ctb], André Carezia [ctb], Vincent Cautaerts [ctb], Eric Chassande-Mottin [ctb], Luca Citi [ctb], Dave Cogdell [ctb], Carlo de Falco [ctb], Carne Draug [ctb], Pascal Dupuis [ctb], John W. Eaton [ctb], R.G.H Eschauzier [ctb], Andrew Fitting [ctb], Alan J. Greenberger [ctb], Mike Gross [ctb], Daniel Gunyan [ctb], Kai Habel [ctb], Kurt Hornik [ctb], Jake Janovetz [ctb], Alexander Klein [ctb], Peter V. Lanspeary [ctb], Bill Lash [ctb], Friedrich Leissh [ctb], Laurent S. Mazet [ctb], Mike Miller [ctb], Petr Mikulik [ctb], Paolo Neis [ctb], Georgios Ouzounis [ctb], Sylvain Pelissier [ctb], Francesco Potortì [ctb], Charles Praplan [ctb], Lukas F. Reichlin [ctb], Tony Richardson [ctb], Asbjorn Sabo [ctb], Thomas Sailer [ctb], Rolf Schirmacher [ctb], Rolf Schirmacher [ctb], Ivan Selesnick [ctb], Julius O. Smith III [ctb], Peter L. Soendergaard [ctb], Quentin Spencer [ctb], Doug Stewart [ctb], P. Sudeepam [ctb], Stefan van der Walt [ctb], Andreas Weber [ctb], P. Sudeepam [ctb], Andreas Weingessel [ctb]
Initial release
2021-05-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.