Learn R Programming

PivotalR (version 0.1.18.5)

sort: Sort a table or view by a set of columns

Description

This function is used to sort a table of view in the database.

Usage

# S4 method for db.obj
sort(x, decreasing = FALSE, INDICES, ...)

Arguments

x

The signature of the method. A db.obj (includes db.table and db.view) object, which points to a table or view in the database.

decreasing

A logical, with default value as FALSE. Should the sort be increasing or decreasing?

INDICES

A list of db.Rquery objects. Each of the list element selects one or multiple columns of x. NULL to order by random().

Further arguments passed to or from other methods. This is currently not implemented.

Value

A db.Rquery object. It is the query object used to sort the db.obj in the database.

See Also

by has similar syntax to this function.

lk or lookat to view portion of the data table

Examples

Run this code
# NOT RUN {
<!-- %% @test .port Database port number -->
<!-- %% @test .dbname Database name -->
## set up the database connection
## Assume that .port is port number and .dbname is the database name
cid <- db.connect(port = .port, dbname = .dbname, verbose = FALSE)

x <- as.db.data.frame(abalone, conn.id = cid, verbose = FALSE)
lk(x, 10)

y  <- sort(x, decreasing = FALSE, list(x$id, x$sex) )
# get the SQL query to be run
content(y)
# get the sorted output
lk(y, 20)

db.disconnect(cid, verbose = FALSE)
# }

Run the code above in your browser using DataLab