1.7.2 Running an Oracle R Enterprise Example Script

You can run an Oracle R Enterprise example script with the demo function. Most of the examples use the iris data set that is in the datasets package that is included in the R distribution.

To run an example script, start R, load the ORE packages with library(ORE), connect to the database, and then use the demo function.

Example 1-7 runs the basic.R example script. In the listing that follows the example, only the first several lines of the output of the script are shown. The script creates an in-memory database object, IRIS_TABLE, which is an ore.frame object. The script then demonstrates that the iris data.frame and the IRIS_TABLE ore.frame have the same structure and contain the same data.

Example 1-7 Running the basic.R Example Script

demo("basic", package = "ORE")
Listing for Example 1-7
R> demo("basic", package = "ORE")

        demo(basic)
        ---- ~~~~~
 
Type  <Return>   to start : 
 
R> #
R> #     O R A C L E  R  E N T E R P R I S E  S A M P L E   L I B R A R Y
R> #
R> #     Name: basic.R
R> #     Description: Demonstrates basic connectivity to database
R> #
R> #
R> #
R> 
R> ## Set page width
R> options(width = 80)
 
R> # Push the built-in iris data frame to the database
R> IRIS_TABLE <- ore.push(iris)
 
R> # Display the class of IRIS_TABLE 
R> class(IRIS_TABLE)
[1] "ore.frame"
attr(,"package")
[1] "OREbase"
 
R> # Basic commands
R> 
R> # Number of rows
R> nrow(iris)
[1] 150
 
R> nrow(IRIS_TABLE)
[1] 150
 
R> # Column names of the data frame
R> names(iris)
[1] "Sepal.Length" "Sepal.Width"  "Petal.Length" "Petal.Width"  "Species"     
 
R> names(IRIS_TABLE)
[1] "Sepal.Length" "Sepal.Width"  "Petal.Length" "Petal.Width"  "Species"     

# The rest of the output is not shown.