warn.and.subset {mvbutils} | R Documentation |
Extract subset and warn about omitted cases
Description
Extract row-subset of a data.frame
according to a condition. If any cases (rows) are omitted, they are listed with a warning. Rows where the condition gives NA are omitted.
Usage
# This is the obligatory format, and is not very useful; look at EXAMPLES instead
warn.and.subset(x, cond,
mess.head=deparse( substitute( x), width.cutoff=20, control=NULL, nlines=1),
mess.cond=deparse( substitute( cond), width.cutoff=40, control=NULL, nlines=1),
row.info=rownames( x), sub=TRUE)
Arguments
x |
data.frame |
cond |
expression to evaluate in the context of |
mess.head |
description of data.frame (e.g. its name) for use in a warning. |
mess.cond |
description of the desired condition for use in a warning. |
row.info |
character vector that will describe rows; omitted elements appear in the warning |
sub |
should |
# ...: just there to keep RCMD CHECK happy– for heaven's sake...
Value
The subsetted data.frame.
See Also
%where.warn%
which is a less-flexible way of doing the same thing
Examples
df <- data.frame( a=1:3, b=letters[1:3])
df1 <- warn.and.subset( df, a %% 2 == 1, 'Boring example data.frame', 'even-valued "a"')
condo <- quote( a %% 2 == 1)
df2 <- warn.and.subset( df, condo, 'Same boring data.frame', deparse( condo), sub=FALSE)