Description Usage Arguments Details Value See Also Examples
Extract a subset of the rows of a dataset using a logical condition.
1 2 |
x |
a dataset object. |
subset |
a logical expression giving the subset condition. |
... |
ignored. |
The subset.dataset
first converts its first argument do a dataset and
then extracts the rows corresponding to the
TRUE
elements in the subset
argument. When evaluating the
subset
condition, the method quotes the argument and then evaluates it
using scope
, with the dataset-converted x
as the first argument.
The method is similar to subset.data.frame
, but method, but it
lacks additional arguments beyond subset
, and it uses a different
evaluation mechanism for the subset
argument.
A dataset containing the rows in x
corresponding to the TRUE
elements of the evaluated subset
condition.
1 2 3 4 5 6 7 8 9 10 | x <- as.dataset(mtcars)
subset(x, cyl == 4)
# equivalent:
subset.dataset(mtcars, cyl == 4)
# scoped evaluation:
gear <- 1:nrow(mtcars)
subset(x, gear == 5) # look for 'gear' in 'x', then the environment
subset(x, I(gear) == 5) # look for 'gear' in the environment
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.