r8filter() gives the rows of a table, a value of a new_table_type(), where a rule() is true,
and r8select() gives columns. Neither changes x, and r8select() copies no
column. x[rule, ] and x[rule, columns] are the same.
Arguments
- x
A value of a table.
- rule
A
rule()withoutwhen. Itsidandmessageare not read.- n_threads
Optional Integer [1, Inf): The threads that the work in Rust may use;
NULLtakesgetOption("r8.n_threads"), whose default is half the logical cores, at most 2 whereR CMD checklimits the cores, and at mostOMP_THREAD_LIMIT. A result is the same for any number of threads.- columns
Character or numeric: The columns, by name or by position, each once.
Value
A value of the type of x. r8select() without a column that the type
requires gives a Raven.
Details
A rule is a value: one rule filters every table that has the columns it names.
!, &, and | make a rule of others.
A bare name in a rule is a column, and val() is the value of an R expression
(val()). The rule is checked against the columns and their types before a row is
read.
Missing cells
A row is kept where the rule is true. Where a cell is missing or NaN, a
comparison is missing, and the row is left out, by the rule and by its negation;
is.na() tests for such a cell. FALSE && NA is false and TRUE || NA true, as in
R.
Whole columns
mean(x), sum(x), min(x), and max(x) read the whole column x, and are
missing where one of its cells is. pmin(a, b) and pmax(a, b) are the least and
the greatest cell of the row.
Errors
A division by zero, sqrt() of a negative number, and log() of a number that is
not positive are errors, unless another part decides the row: x > 0 && log(x) > 1
is false where x is 0.
Examples
#> <raven table> 90 rows ⨉ 5 columns
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> double double double double factor
#> 1 7.0 3.2 4.7 1.4 versicolor
#> 2 6.4 3.2 4.5 1.5 versicolor
#> 3 6.9 3.1 4.9 1.5 versicolor
#> 4 5.5 2.3 4.0 1.3 versicolor
#> 5 6.5 2.8 4.6 1.5 versicolor
#> ... 80 rows not shown
#> 86 6.7 3.0 5.2 2.3 virginica
#> 87 6.3 2.5 5.0 1.9 virginica
#> 88 6.5 3.0 5.2 2.0 virginica
#> 89 6.2 3.4 5.4 2.3 virginica
#> 90 5.9 3.0 5.1 1.8 virginicar8filter(r, wide & rule(Species == "versicolor"))#> <raven table> 40 rows ⨉ 5 columns
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> double double double double factor
#> 1 7.0 3.2 4.7 1.4 versicolor
#> 2 6.4 3.2 4.5 1.5 versicolor
#> 3 6.9 3.1 4.9 1.5 versicolor
#> 4 5.5 2.3 4.0 1.3 versicolor
#> 5 6.5 2.8 4.6 1.5 versicolor
#> ... 30 rows not shown
#> 36 5.6 2.7 4.2 1.3 versicolor
#> 37 5.7 3.0 4.2 1.2 versicolor
#> 38 5.7 2.9 4.2 1.3 versicolor
#> 39 6.2 2.9 4.3 1.3 versicolor
#> 40 5.7 2.8 4.1 1.3 versicolorr8select(r, c("Species", "Petal.Width"))#> <raven table> 150 rows ⨉ 2 columns
#> Species Petal.Width
#> factor double
#> 1 setosa 0.2
#> 2 setosa 0.2
#> 3 setosa 0.2
#> 4 setosa 0.2
#> 5 setosa 0.2
#> ... 140 rows not shown
#> 146 virginica 2.3
#> 147 virginica 1.9
#> 148 virginica 2.0
#> 149 virginica 2.3
#> 150 virginica 1.8r[!wide, c("Species", "Petal.Width")]#> <raven table> 60 rows ⨉ 2 columns
#> Species Petal.Width
#> factor double
#> 1 setosa 0.2
#> 2 setosa 0.2
#> 3 setosa 0.2
#> 4 setosa 0.2
#> 5 setosa 0.2
#> ... 50 rows not shown
#> 56 versicolor 1.0
#> 57 versicolor 1.1
#> 58 versicolor 1.0
#> 59 versicolor 1.0
#> 60 versicolor 1.1