2.4.2.4 About Coercing R and Oracle Machine Learning for R Class Types
Some OML4R functions coerce R objects and class types to OML4R ore
objects and types.
The generic as.ore
function coerces in-memory R objects to
ore
objects. The more specific functions, such as
as.ore.character
, coerce objects to specific types. The
ore.push
function implicitly coerces R class types to ore
class types and the ore.pull
function coerces ore
class types
to R class types. For information on those functions, see "Create Temporary Database Tables".
Example 2-5 Coercing R and OML4R Class Types
This example illustrates coercing R objects to ore
objects. creates an R integer
object and then uses the generic method as.ore
to coerce it to an ore
object, which is an ore.integer
. The example coerces the R object to various other ore
class types. For an example of using as.factor
in Embedded R Execution function, see Example 10-9.
x <- 1:10 class(x) X <- as.ore(x) class(X) Xn <- as.ore.numeric(x) class(Xn) Xc <- as.ore.character(x) class(Xc) Xc Xf <- as.ore.factor(x) XfListing for Example 2-5
R> x <- 1:10
R> class(x)
[1] "integer"
R> X <- as.ore(x)
R> class(X)
[1] "ore.integer"
attr(,"package")
[1] "OREbase"
R> Xn <- as.ore.numeric(x)
R> class(Xn)
[1] "ore.numeric"
attr(,"package")
[1] "OREbase"
R> Xc <- as.ore.character(x)
R> class(Xc)
[1] "ore.character"
attr(,"package")
[1] "OREbase"
R> Xc
[1] "1" "2" "3" "4" "5" "6" "7" "8" "9" "10"
R> Xf <- as.ore.factor(x)
R> Xf
[1] 1 2 3 4 5 6 7 8 9 10
Levels: 1 10 2 3 4 5 6 7 8 9
Parent topic: Transparency Layer Support for R Data Types and Classes