lgrep | R Documentation |
Often you want the elements of a vector (or its names or levels) that
meet a certain pattern. But grep
only gives you the position, so
these functions are designed to give you that.
fgrep( pattern, x, ... )
ngrep( pattern, x, ... )
lgrep( pattern, x, ... )
pattern |
Pattern searched for. |
x |
Object where |
... |
Arguments passed on to |
Elements of the input x
(fgrep
) or its names
attribute (ngrep
) or levels attribute (lgrep
).
Bendix Carstensen, b@bxc.dk, http://bendixcarstensen.com
grep
ff <- factor( ll <- paste( sample( letters[1:3], 20, replace=TRUE ),
sample( letters[1:3], 20, replace=TRUE ), sep="" ) )
ff
fgrep( "a", ff )
fgrep( "a", ll )
ngrep( "a", ff )
lgrep( "a", ff )
lgrep( "a", ff, invert=TRUE )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.