Given a hyperframe, return the subset specified by imposing a condition on each row, and optionally by choosing only some of the columns.
# S3 method for hyperframe
subset(x, subset, select, ...)
A hyperframe.
A hyperframe pattern (object of class "hyperframe"
.
Logical expression indicating which points are to be kept.
The expression may involve the names of columns of x
and will be evaluated by with.hyperframe
.
Expression indicating which columns of marks should be kept.
Arguments passed to [.hyperframe
such as drop
and strip
.
Adrian Baddeley Adrian.Baddeley@curtin.edu.au
, Rolf Turner r.turner@auckland.ac.nz
and Ege Rubak rubak@math.aau.dk
This is a method for the generic function subset
.
It extracts the subset of rows of x
that satisfy the logical expression
subset
, and retains only the columns of x
that are
specified by the expression select
. The result is always a
hyperframe.
The argument subset
determines the subset of rows that
will be extracted. It should be a logical expression.
It may involve the names of columns of x
.
The default is to keep all points.
The argument select
determines which columns of x
will be retained.
It should be an expression involving the names of columns
(which will be interpreted as integers representing the positions of
these columns). For example if there are columns named
A
to Z
, then select=D:F
is a valid expression
and means that columns D
, E
and F
will be
retained. Similarly select=-(A:C)
is valid and means that columns
A
to C
will be deleted.
The default is to retain all columns.
Setting subset=FALSE
will remove all the rows.
Setting select=FALSE
will remove all the columns.
The result is always a hyperframe.
subset
,
[.hyperframe
a <- subset(flu, virustype=="wt")
aa <- subset(flu, minnndist(pattern) > 10)
aaa <- subset(flu, virustype=="wt", select = -pattern)
Run the code above in your browser using DataLab