keep: Keep or drop symbols

Description Usage Arguments Note Author(s) Examples

Description

Keep or drop symbols

Usage

1
2
keep(a, yes)
discard(a, no)

Arguments

a

Object of class free

yes,no

Specification of symbols to either keep (yes) or discard (no), coerced to a free object

Note

Function keep() needs an explicit return() to prevent it from returning invisibly.

The functions are vectorised in the first argument but not the second.

The second argument—the symbols to keep or discard—is formally a vector of nonnegative integers, but the functions coerce it to a free object. The symbols kept or dropped are the union of the symbols in the elements of the vector. Function discard() was formerly known as drop() but this conflicted with base::drop().

These functions have nothing in common with APL's take() and drop().

Author(s)

Robin K. S. Hankin

Examples

1
2
3
4
5
6
7
8
x <- rfree(10,5,8)

keep(x,abc(4))           # keep only symbols a,b,c,d
discard(x,as.free('cde'))   # drop symbols c,d,e



x[1:4] %<>% keep(alpha(3))  # keep only abc in first 4 elements of x

RobinHankin/freegroup documentation built on Aug. 13, 2019, 3:54 p.m.