2.2.3.3 Create Temporary Database Tables
You can create temporary database tables, and their corresponding proxy ore.frame
objects, from local R data.frame objects with the ore.push
function.
With the ore.pull
function you can create a local R object that contains a copy of data represented by an OML4R proxy object.
The ore.push
function translates an R object into an OML4R object of the appropriate data type. The ore.pull
function takes an ore
class object and returns an R object. If the input object is an ore.list
, the ore.pull
function creates a data.frame
and translates the data of each database column into the appropriate R representation.
Note:
You can pull data to a local R data.frame
only if the data can fit into the R session memory. Also, even if the data fits in memory but is still very large, you may not be able to perform many, or any, R functions in the client R session.
Unless you explicitly save the proxy objects in a datastore in the database that were created using the ore.push
function, the temporary tables and proxy objects are discarded when you quit your R session.
Example 2-14 Using ore.push and ore.pull to Move Data
This example demonstrates pushing an R data.frame
object to the database as a temporary database table with an associated ore.frame
object, iris_of
, then creating another ore.frame
object, iris_of_setosa
, by selecting one column from iris_of
, and then pulling the iris_of_setosa
object into the local R session memory as a data.frame
object. The example displays the class of some of the objects.
class(iris) # Push the iris data frame to the database. iris_of <- ore.push(iris) class(iris_of) # Display the data type of the Sepal.Length column in the data.frame. class(iris$Sepal.Length) # Display the data type of the Sepal.Length column in the ore.frame. class(iris_of$Sepal.Length) # Filter one column of the data set. iris_of_setosa <- iris_of[iris_of$Species == "setosa", ] class(iris_of_setosa) # Pull the selected column into the local R memory. local_setosa = ore.pull(iris_of_setosa) class(local_setosa)Listing for This Example
R> class(iris) [1] "data.frame" R> # Push the iris data frame to the database. R> iris_of <- ore.push(iris) R> class(iris_of) [1] "ore.frame" attr(,"package") [1] "OREbase" R> # Display the data type of the Sepal.Length column in the data.frame. R> class(iris$Sepal.Length) [1] "numeric" R> # Display the data type of the Sepal.Length column in the ore.frame. R> class(iris_of$Sepal.Length) [1] "ore.numeric" attr(,"package") [1] "OREbase" R> # Filter one column of the data set. R> iris_of_setosa <- iris_of[iris_of$Species == "setosa", ] R> class(iris_of_setosa) [1] "ore.frame" attr(,"package") [1] "OREbase" R> # Pull the selected column into the local R memory. R> local_setosa = ore.pull(iris_of_setosa) R> class(local_setosa) [1] "data.frame"
Parent topic: Create and Manage R Objects in Oracle Database