
Order a table by a set of columns (not general expressions) and limit number of rows in that order.
orderby(source, orderby, ..., desc = FALSE, limit = NULL)
source to select from.
order by column names.
force later arguments to be bound by name
logical if TRUE reverse order
number limit row count.
select columns node.
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 ot pulling data to an in-memory data.frame
(
which does preserve row order).
# NOT RUN {
my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
d <- dbi_copy_to(my_db, 'd',
data.frame(AUC = 0.6, R2 = 0.2))
eqn <- orderby(d, "AUC", desc=TRUE, limit=4)
cat(format(eqn))
sql <- to_sql(eqn, my_db)
cat(sql)
DBI::dbGetQuery(my_db, sql)
DBI::dbDisconnect(my_db)
# }
Run the code above in your browser using DataLab