次の例に示すように、demo関数を使用してOracle R Enterpriseのサンプル・スクリプトのリストを表示できます。
例1-6 Oracle R Enterpriseの例をリストするためのデモの使用方法
demo(package = "ORE")
R> demo(package = "ORE") Demos in package 'ORE': aggregate Aggregation analysis Basic analysis & data processing operations basic Basic connectivity to database binning Binning logic columnfns Column functions cor Correlation matrix crosstab Frequency cross tabulations datastore Datastore operations datetime Date/Time operations derived Handling of derived columns distributions Distribution, density, and quantile functions do_eval Embedded R processing esm Exponential smoothing method freqanalysis Frequency cross tabulations glm Generalized Linear Models graphics Demonstrates visual analysis group_apply Embedded R processing by group hypothesis Hypothesis testing functions matrix Matrix related operations nulls Handling of NULL in SQL vs. NA in R odm_ai Oracle Data Mining: attribute importance odm_ar Oracle Data Mining: association rules odm_dt Oracle Data Mining: decision trees odm_em Oracle Data Mining: expectation maximization (12.2) odm_esa Oracle Data Mining: explicit semantic analysis (12.2) odm_glm Oracle Data Mining: generalized linear models odm_kmeans Oracle Data Mining: enhanced k-means clustering odm_nb Oracle Data Mining: naive Bayes classification odm_nmf Oracle Data Mining: non-negative matrix factorization odm_oc Oracle Data Mining: o-cluster odm_partition Oracle Data Mining: partition model (12.2) odm_ralg Oracle Data Mining: extensible R algorithm (12.2) odm_svd Oracle Data Mining: singular value decomposition (12.2) odm_svm Oracle Data Mining: support vector machines ore_dplyr Data manipulation similar to dplyr pca Principal Component Analysis push_pull RDBMS <-> R data transfer randomForest Random forest model rank Attributed-based ranking of observations reg Ordinary least squares linear regression row_apply Embedded R processing by row chunks sampling Random row sampling and partitioning of an ore.frame script Create, list, load, drop, grant, and revoke R scripts sql_like Mapping of R to SQL commands stepwise Stepwise OLS linear regression summary Summary functionality table_apply Embedded R processing of entire table
Oracle R Enterpriseのサンプル・スクリプトはdemo関数を使用して実行できます。ほとんどの例では、R Distributionに含まれているdatasetsパッケージにあるirisデータセットを使用します。
サンプル・スクリプトを実行するには、Rを起動し、OREパッケージをlibrary(ORE)を指定してロードし、データベースに接続してから、demo関数を使用します。
例1-7 basic.Rサンプル・スクリプトの実行
この例は、basic.Rサンプル・スクリプトを実行します。例の後にあるリストには、スクリプトの出力の最初の数行のみが表示されています。このスクリプトはインメモリー・データベース・オブジェクトであるIRISを作成しますが、これはore.frameオブジェクトです。このスクリプトは次に、irisのdata.frameおよびIRISのore.frameが同じ構造を持ち、同じデータを含んでいることを示します。
demo("basic", package = "ORE")
この例のリスト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 <- ore.push(iris)
R> # Display the class of IRIS
R> class(IRIS)
[1] "ore.frame"
attr(,"package")
[1] "OREbase"
R> # Basic commands
R>
R> # Number of rows
R> nrow(iris)
[1] 150
R> nrow(IRIS)
[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)
[1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
# The rest of the output is not shown.