order_rows | R Documentation |
Order a table by a set of columns (not general expressions) and limit number of rows in that order.
order_rows(
source,
cols = NULL,
...,
reverse = NULL,
limit = NULL,
env = parent.frame()
)
source |
source to select from. |
cols |
order by columns ascending. |
... |
force later arguments to be bound by name |
reverse |
character, which columns to reverse ordering of to descending. |
limit |
number limit row count. |
env |
environment to look to. |
Note: this is a relational operator in that it takes a table that
is a relation (has unique rows) to a table that is still a relation.
However, most relational systems do not preserve row order in storage or between
operations. So without the limit set this is not a useful operator except
as a last step prior to pulling data to an in-memory data.frame
(
which does preserve row order).
order_by node.
if (requireNamespace("DBI", quietly = TRUE) && requireNamespace("RSQLite", quietly = TRUE)) {
my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
d <- rq_copy_to(my_db, 'd',
data.frame(AUC = 0.6, R2 = 0.2))
optree <- order_rows(d, cols = "AUC", reverse = "AUC", limit=4)
cat(format(optree))
sql <- to_sql(optree, my_db)
cat(sql)
print(DBI::dbGetQuery(my_db, sql))
DBI::dbDisconnect(my_db)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.