2.2.3.4.1 About Ordering in ore.frame Objects
R objects such as vector
and data.frame
have an implicit ordering of their elements.
The data in an Oracle Database table is not necessarily ordered. For some R operations, ordering is useful whereas for other operations it is unnecessary. By ordering an ore.frame
, you are able to index the ore.frame
object by using either integer or character indexes.
Using an ordered ore.frame
object that is a proxy for a SQL query can be time-consuming for a large data set. Therefore, although OML4R attempts to create ordered ore.frame
objects by default, it also provides the means of creating an unordered ore.frame
object.
When you invoke the ore.sync
function to create an OML4R ore.frame
object as a proxy for a SQL query, you can use the use.keys
argument to specify whether the ore.frame
can be ordered or must be unordered.
An ore.frame
object can be ordered if one or more of the following conditions are true:
-
The value of the
use.keys
argument of theore.sync
function isTRUE
and a primary key is defined on the underlying table -
The row names of the
ore.frame
constitute a unique tuple -
The
ore.frame
object is produced by certain functions such asaggregate
andcbind
-
All of the
ore.frame
objects that are input arguments to relevant OML4R functions are ordered
An ore.frame
object is unordered if one or more of the following conditions are true:
-
The value of the
use.keys
argument of theore.sync
function isFALSE
-
No primary key is defined on the underlying table and either the row names of the
ore.frame
object are not specified or the row names of theore.frame
object are set toNULL
-
One or more of the
ore.frame
objects that are input arguments to relevant OML4R functions are unordered
An unordered ore.frame
object has null row names. You can determine whether an ore.frame
object is ordered by invoking is.null
on the row names of the objects, as shown in the last lines of Example 2-15. If the ore.frame
object is unordered, is.null
returns an error.
See Also:
Parent topic: Create Ordered and Unordered ore.frame Objects