A.4 Verifying the Oracle Machine Learning for R Installation
To verify that the basic functionality of Oracle Machine Learning for R is working, establish a connection to an Oracle Machine Learning for R server and run several basic functions.
Note:
To start and use Oracle Machine Learning for R, your database user must have the privileges required for Oracle Machine Learning for R installation. See User Requirements for details.
Example A-2 Connecting to an Oracle Machine Learning for R Server
To connect the an Oracle Machine Learning for R client to an Oracle Machine Learning for R server:
-
Type this command to start Oracle Machine Learning for R:
$ ORE R> library(ORE)
-
Type this command to connect to the Oracle Machine Learning for R server. The following example connects user
OML_USERto the databaseorclon the server hostserv1using port 1521:> ore.connect(user="OML_USER", sid="orcl", host="serv1", password="OML_USERpsw", port=1521, all=TRUE) Loading required package: ROracle Loading required package: DBI -
Run
ore.is.connectedto validate the connection. If the connection is successful, the function returnsTRUE:> ore.is.connected() [1] TRUE
Example A-3 Listing the Database Tables Accessible in a Schema
The ore.ls function
lists the ore.frame proxy objects
that correspond to database tables in the
environment for a schema. In the following
example, TABLE1 and
TABLE2 exist in the current
schema:
> ore.ls() [1] "TABLE1" "TABLE2"
Example A-4 Pushing an R Data Frame to the Database
The ore.push function
pushes a local R object into an Oracle Machine Learning for R object of the appropriate data type in
the database. The following example creates an R
data.frame and pushes it an
ore.frame object in the
database.
df <- data.frame(a="abc",
b=1.456,
c=TRUE,
d=as.integer(1))
of <- ore.push(df)
Example A-5 Running an Embedded R Function
The ore.doEval function runs the specified function in an R engine on the database server and returns the results. This example declares a function in the ore.doEval invocation.
> ore.doEval(function() { 123 })
[1] 123
Parent topic: A Sample Installation of Oracle Machine Learning for R