The Oracle R Enterprise transparency layer is implemented by the
OREstats packages. These Oracle R Enterprise packages contain overloaded methods of functions in the open source R
stats packages, respectively. The Oracle R Enterprise packages also contain Oracle R Enterprise versions of some of the open source R functions.
With the methods and functions in these packages, you can create R objects that specify data in an Oracle Database instance. When you execute an R expression that uses such an object, the method or function transparently generates a SQL query and sends it to the database. The database then executes the query and returns the results of the operation as an R object.
A database table or view is represented by an
ore.frame object, which is a subclass of
data.frame. Other Oracle R Enterprise classes inherit from corresponding R classes, such as
vector. Oracle R Enterprise maps Oracle Database data types to Oracle R Enterprise classes, such as
ore.integer. For more information on Oracle R Enterprise data types and object mappings, see "Transparency Layer Support for R Data Types and Classes".
You can use the transparency layer methods and functions to prepare database-resident data for analysis. You can then use functions in other Oracle R Enterprise packages to build and fit models and use them to score data. For large data sets, you can do the modeling and scoring using R engines embedded in Oracle Database.
"Transparency Layer Support for R Data Types and Classes" for information on the correspondences between R, Oracle R Enterprise, and SQL data types and objects
Example 1-2 Finding the Mean of the Petal Lengths by Species in R
This example illustrates the translation of an R function invocation into SQL. It uses the overloaded Oracle R Enterprise
aggregate function to get the mean of the petal lengths from the
IRIS_TABLE object from Example 1-2.
aggplen = aggregate(IRIS_TABLE$Petal.Length, by = list(species = IRIS_TABLE$Species), FUN = mean) aggplenListing for Example 1-2
R> aggplen = aggregate(IRIS_TABLE$Petal.Length, by = list(species = IRIS_TABLE$Species), FUN = mean) R> aggplen species x setosa setosa 1.462 versicolor versicolor 4.260 virginica virginica 5.552
Example 1-3 SQL Equivalent of Example 1-2
This example shows the SQL equivalent of the
aggregate function in Example 1-2.
SELECT "Species", AVG("Petal.Length") FROM IRIS_TABLE GROUP BY "Species" ORDER BY "Species"; Species AVG("PETAL.LENGTH") ----------- ------------------- setosa 1.4620000000000002 versicolor 4.26 virginica 5.552