Subset Dialog Function
DESCRIPTION:
The function called by the Subset dialog. This function is used to
create a subset of a data.frame based on a specified subset
expression. This subset may be indicated by either returning the
data.frame supplemented with a logical column indicating group
membership, or by returning a data.frame which is a subset of the
original data.frame.
USAGE:
menuSubset(data, subset.expression, subset.columns, result.type="Data Set",
subset.col.name="subset", save.name=NA, show.p=.Options$show.data.in.view,
keep.na.rows=F)
REQUIRED ARGUMENTS:
- data
-
Data.frame from which to create the subset.
- subset.expression
-
List such that
unlist
of the evaluated expression
contains row names, row numbers, or a logical vector indicating which
rows to include in the subset. This is specified as a list so that
users may specify
"1, 2, 3"
or "Mileage > mean(Mileage)" in the
Subset dialog and obtain the specified rows or the result of evaluating
the conditional expression.
OPTIONAL ARGUMENTS:
- subset.columns
-
Vector or list of column names or numbers specifying which columns to
include in the subset data frame. If missing, all columns are included.
- result.type
-
Character string
"Data Set"
or
"Add Column"
. If
"Data Set"
, the
result will be a data.frame which contains a subset of the rows in
data
. If
"Add Column"
, the result will be a data.frame with all of the rows of
data
and a new logical column indicating whether each row is in the specified
subset.
- subset.col.name
-
Character string giving name for new subset indicator column if
result.type
is
"Add Column"
.
- save.name
-
character string giving name under which to save result. If this is
specified the result will be assigned to the working database under the
given name, and will also be returned invisibly.
- show.p
-
logical flag: if
TRUE
,
save.name
is specified, and the Windows S-PLUS GUI
is active, the result will be displayed in a Data Window.
- keep.na.rows
-
logical flag: if
TRUE
the rows for which the condition is
NA
will be
retained in the subset. By default rows for which the condition is
NA
are
excluded from the subset.
VALUE:
Data.frame as described above under
result.type
.
EXAMPLES:
menuSubset(fuel.frame,list(1,2,3))
menuSubset(fuel.frame,list(Mileage>mean(Mileage)))