3.2.3.3 一時データベース表の作成
ore.push
関数を使用して、ローカルR data.frameオブジェクトから一時データベース表およびそれに対応するプロキシore.frame
オブジェクトを作成できます。
ore.pull
関数を使用して、OML4Rプロキシ・オブジェクトが表すデータのコピーを含むローカルのRオブジェクトを作成できます。
ore.push
関数は、Rオブジェクトを適切なデータ型のOML4Rオブジェクトに変換します。ore.pull
関数は、ore
クラス・オブジェクトを取得してRオブジェクトを返します。入力オブジェクトがore.list
の場合、ore.pull
関数はdata.frame
を作成し、各データベース列のデータを適切なR表現に変換します。
ノート:
データがRセッション・メモリーに適合する場合にのみ、データをローカルRのdata.frame
にプルできます。また、データがメモリーに適合しても非常に大きい場合は、多数の、またはすべてのR関数をクライアントRセッションで実行できない可能性があります。
ore.push
関数を使用して作成されたデータベースのデータストアにプロキシ・オブジェクトを明示的に保存しないかぎり、Rセッションの終了時に一時表およびプロキシ・オブジェクトは破棄されます。
例3-14 データを移動するためのore.pushおよびore.pullの使用方法
この例は、Rのdata.frame
オブジェクトを関連するore.frame
オブジェクト(iris_of
)とともに一時データベース表としてデータベースにプッシュし、iris_of
から1列を選択することによって別のore.frame
オブジェクト(iris_of_setosa
)を作成した後に、iris_of_setosa
オブジェクトをdata.frame
オブジェクトとしてローカルのRセッション・メモリーにプルすることを示します。この例では、一部のオブジェクトのクラスを表示します。
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)この例のリスト
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"