ヘッダーをスキップ
Oracle® R Enterpriseインストレーションおよび管理ガイド
リリース1.4 for Windows, Linux, Solaris, and AIX
E52976-01
  目次へ移動
目次
索引へ移動
索引

前
 
次
 

Oracle R Enterpriseのサンプル・インストール

この付録では、Oracle R EnterpriseをLinuxサーバーおよびWindowsクライアントにインストールするための一般的な手順を説明します。ここでは、次の項目について説明します。


関連項目:

Oracle R Enterpriseのアンインストールの詳細は第8章を参照してください。

A.1 Oracle R Enterpriseのサンプル・インストール環境について

サーバー・コンピュータについて: 

  • サーバーでOracle Linux 5が稼働しています。

  • サーバーからインターネットおよびOracle Public Yumにアクセスできます。

  • サーバーにOracle Database Enterprise Edition 12.1がインストールされています。

  • 環境変数:

    • $ORACLE_SIDでデータベースの識別子(SID)を指定します。

    • $ORACLE_HOMEでデータベースのホーム・ディレクトリを指定します。

    • $LD_LIBRARY_PATH$ORACLE_HOME/libを含めます。

    • $PATH$ORACLE_HOME/binを含めます。

  • インストール実行者のLinuxユーザーID:

    • Oracle R Distributionをインストールするためのsudo権限またはrootアクセスがあります。

    • Oracle R Enterpriseをインストールおよび使用するためのdbaグループのメンバーです。

    • $ORACLE_HOME/libへの書込み権限があります。

クライアント・コンピュータについて: 

  • クライアントで64ビット版Windowsが稼働しています。

  • クライアントからインターネットにアクセスできます。

A.2 Oracle R Enterpriseのサーバーへのインストール

Oracle R Enterpriseをサーバー・コンピュータにインストールするには、まずOracle Databaseがインストールされていること、および第A.1項の指定のとおりに環境が構成されていることを確認します。次に、これらの手順を順序どおりに実行します。

  1. Oracle R Distributionのインストール

  2. Oracle R Enterprise Serverのインストール

  3. Oracle R Enterprise Supporting Packagesのサーバーへのインストール

  4. Oracle R Enterpriseのデータベース・ユーザーの作成

A.2.1 Oracle R Distributionのインストール

Oracle R DistributionをOracle Public Yumからサーバーにインストールするには、次の手順を実行します。

  1. rootでログインして、/etc/yum.repos.dに変更します。

    # cd /etc/yum.repos.d
    
  2. ディレクトリの内容をリストして、Yumの構成ファイルが存在しているかどうかを確認します。Oracle Linux 5用のYumの構成ファイルはpublic-yum-el5.repoと呼ばれます。

    public-yum-el5.repoが存在しない場合は、次のコマンドを実行してOracle Public Yumからこのファイルをダウンロードします。

    # wget http://public-yum.oracle.com/public-yum-el5.repo
    
  3. テキスト・エディタでpublic-yum-el5.repoを開いて、latestおよびaddonsenabled=1を指定します。

    [el5_latest]
    enabled=1
    
    [el5_addons]
    enabled=1
    
  4. 次のコマンドを実行してOracle R Distribution 3.0.1をインストールします。

    # yum install R-3.0.1
    

A.2.2 Oracle R Enterprise Serverのインストール

Oracle R Enterprise Serverには、Oracle DatabaseのRQSYSスキーマと、Oracle R Enterpriseパッケージおよび共有ライブラリが含まれます。次の手順に従って、Oracle R Enterprise Serverをダウンロードおよびインストールします。

Oracle R Enterprise Serverをダウンロードするには次の手順を実行します。

  1. Oracle R Enterprise Serverコンポーネントのインストール・ディレクトリを作成します。ディレクトリには任意の名前を使用できます。例:

    /myhome/myoreserver
    
  2. Oracle Technology NetworkのOracle R Enterprise Downloadsページに移動します。

    http://www.oracle.com/technetwork/database/options/advanced-analytics/r-enterprise/ore-downloads-1502823.html

  3. ライセンス契約に同意します。

  4. 「Oracle R Enterprise Downloads (v1.4)」の下で、「Oracle R Enterprise Server Install for Oracle Database on Linux 64 bit (92M)」を選択します。

  5. ファイルを、手順1で作成したインストール・ディレクトリにダウンロードして解凍します。

    % cd /myhome/myoreserver
    % unzip ore-server-linux-x86-64-1.4.zip
    
  6. ファイルを解凍すると、serverサブディレクトリが作成されます。インストール・ディレクトリの内容は、次のようにリストされます。

    % ls
    ore-server-linux-x86-64-1.4.zip
    server/
    

Oracle R Enterprise Serverをインストールするには次の手順を実行します。

  1. serverサブディレクトリに移動します。

    % cd server
    
  2. インストール・スクリプトを実行します。

    % ./install.sh
    
  3. インストール・スクリプトによって、パスワードおよびRQSYSスキーマの永続表領域および一時表領域の名前の入力が求められます。デフォルトの表領域は、SYSAUXおよびTEMPです。デフォルト名をそのまま使用する場合は、[Enter]を押します。

A.2.3 Oracle R Enterprise Supporting Packagesのサーバーへのインストール

Oracle R Enterprise Supporting Packagesは、オープン・ソースRのパッケージで、Oracle R Enterpriseをサポートします。Supporting Packagesは、クライアントとサーバーの両方にインストールする必要があります。

Oracle R Enterprise Supporting Packagesをダウンロードするには、次の手順を実行します。

  1. Oracle R Enterprise Downloadsページに移動します。

    http://www.oracle.com/technetwork/database/options/advanced-analytics/r-enterprise/ore-downloads-1502823.html

  2. ライセンス契約に同意します。

  3. 「Oracle R Enterprise Downloads (v1.4)」の下で「Oracle R Enterprise Supporting Packages for Linux 64-bit Platform (1.2M)」を選択します。

  4. ファイルを、第A.2.2項で作成したインストール・ディレクトリにダウンロードして解凍します。

    % cd /myhome/myoreserver
    % unzip ore-supporting-linux-x86-64-1.4.zip
    
  5. ファイルを解凍すると、supportingサブディレクトリが作成されます。インストール・ディレクトリの内容は、次のようにリストされます。

    % ls
    ore-server-linux-x86-64-1.4.zip
    ore-supporting-linux-x86-64-1.4.zip
    server/
    supporting/
    

    supportingサブディレクトリには次のパッケージが移入されます。

    cairo_1.5-5
    DBI_0.2-7
    png_0.1-7.zip
    ROracle_1.1-11.zip
    

Oracle R Enterprise Supporting Packagesをインストールするには、次の手順を実行します。

  1. supportingサブディレクトリに移動して、その内容をリストします。

    % cd supporting
    % ls
    cairo_1.5-5_R_x86_64-unknown-linux-gnu.tar.gz
    DBI_0.2-7_R_x86_64-unknown-linux-gnu.tar.gz
    png_0.1-7_R_x86_64-unknown-linux-gnu.tar.gz
    ROracle_1.1-11_R_x86_64-unknown-linux-gnu.tar.gz
    
  2. 次の順序でパッケージをインストールします。

    ORE CMD INSTALL ROracle_1.1-11_R_x86_64-unknown-linux-gnu.tar.gz
    ORE CMD INSTALL DBI_0.2-7_R_x86_64-unknown-linux-gnu.tar.gz
    ORE CMD INSTALL png_0.1-7_R_x86_64-unknown-linux-gnu.tar.gz
    ORE CMD INSTALL cairo_1.5-5_R_x86_64-unknown-linux-gnu.tar.gz
    

    パッケージは$ORACLE_HOME/R/libraryにインストールされます。

A.2.4 Oracle R Enterpriseのデータベース・ユーザーの作成

次の手順に従って、Oracle R Enterpriseのデータベース・ユーザーを作成します。

  1. Oracle R Enterpriseのserverサブディレクトリに移動します。

    % cd /myhome/myoreserver/server/
    
  2. demo_userスクリプトを実行します。

    % ./demo_user.sh
    
  3. スクリプトによって環境が検証された後に、次のように表示されます。

    Do you wish to create an ORE user? [yes]
    

    Oracle R Enterpriseの新規ユーザーを作成するには、yesと入力するか[Enter]を押します。

    既存のユーザーをOracle R Enterpriseで有効にするには、noと入力します。

  4. 新しいユーザーを作成するには、ユーザー名およびパスワードを指定します。デフォルトのユーザー名はrquserです。

    • このユーザーの永続表領域を指定します。デフォルトはUSERSです。

    • このユーザーの一時表領域を指定します。デフォルトはTEMPです。

    既存ユーザーを変更するには、ユーザー名を入力します。

  5. スクリプトが完了した後、sysdbaでSQL*Plusを起動してOracle R Enterpriseで必要とされるユーザー権限を付与します。ユーザーrquserに対して次を実行します。

    sqlplus /  AS SYSDBA
    GRANT CREATE TABLE TO RQUSER;
    GRANT CREATE PROCEDURE TO RQUSER;
    GRANT CREATE VIEW TO RQUSER;
    GRANT CREATE MINING MODEL TO RQUSER;
    GRANT RQADMIN to RQUSER;
    GRANT UNLIMITED TABLESPACE TO RQUSER;
    EXIT;
    

A.3 Oracle R Enterpriseのクライアントへのインストール

Oracle R Enterpriseをクライアント・コンピュータにインストールするには、まずWindows環境が第A.1項に指定されている要件を満たしていることを確認します。次に、これらの手順を実行します。

A.3.1 WindowsクライアントへのOracle R Distributionのインストール

Oracle R Distributionをインストールする前に、ご使用のMicrosoft WindowsのバージョンがOracle R Enterpriseでサポートされていることを確認します。表1-1「Oracle R Enterpriseのプラットフォーム要件」を参照してください。

WindowsにOracle R Distributionをインストールするには、次の手順を実行します。

  1. Oracle R Distributionのオープン・ソース・ソフトウェアのダウンロード・ページに移動します。

    https://oss.oracle.com/ORD/

  2. 「R 3.0.1 Downloads」の下で、「Windows 64 bit」「R Distribution」を選択します。ファイルをコンピュータに保存します。

    ORE-3.0.1-win.zip
    
  3. ファイルを解凍すると、実行可能ファイルが抽出されます。

    ORE-3.0.1-win.exe
    
  4. Oracle R Distributionのインストールを開始するには、実行可能ファイルをダブル・クリックします。

  5. 説明に従って、インストールを完了してください。

A.3.2 Oracle Instant Clientのインストール

Oracle R EnterpriseにはOracle Database Clientが必要です。Oracleホーム・ディレクトリにインストールする必要がある完全なDatabase Clientのかわりに、Oracle Instant Clientをインストールすることができます。

Oracle Instant Clientをダウンロードおよびインストールするには、次の手順を実行します。

  1. Oracle R Enterpriseクライアント・コンポーネントのインストール・ディレクトリを作成します。ディレクトリには任意の名前を使用できます。例:

    c:\myoreclient
    
  2. Oracle Technology NetworkのOracle Database Instant Clientページに移動します。

    http://www.oracle.com/technetwork/database/features/instant-client/

  3. 「See Instant Client Downloads」を選択します。

  4. Instant Client Downloadsページで「Instant Client for Microsoft Windows (x64)」を選択します。

  5. ライセンス契約に同意します。

  6. Oracle Database 12.1の場合は、「Version 12.1.0.1.0」の下の「Instant Client Package - Basic」または「Instant Client Package - Basic Lite」を選択します。

  7. ファイルを、手順1で作成したインストール・ディレクトリに保存します。たとえば、「Basic」パッケージを選択した場合は、次のファイルがダウンロードされます。

    c:\myoreclient\instantclient-basic-windows.x64-12.1.0.1.0.zip
    
  8. ファイルを解凍します。

    ファイルを解凍すると、instantclient_12_1サブディレクトリが作成されます。インストール・ディレクトリの内容は、次のように表示されます。

    myoreclient
      instantclient_12_1
        vc10
        vc11
    
  9. Instant Client Downloadsページに戻ります。

    http://www.oracle.com/technetwork/topics/winx64soft-089540.html

  10. ライセンス契約に合意して、「Instant Client Package - SDK」を選択します。ファイルを手順1で作成したディレクトリに保存します。

    c:\myoreclient\instantclient-sdk-windows.x64-12.1.0.1.0.zip
    
  11. ファイルを解凍します。

    ファイルを解凍すると、sdkサブディレクトリが作成されます。インストール・ディレクトリの内容は、次のように表示されます。

    myoreclient
      instantclient_12_1
        help
        sdk
        vc10
        vc11
    
  12. 環境変数OCI_LIB64およびPATHにInstant Clientのフル・パスを追加します。次の手順では、これらの変数に、この例で使用しているパス、c:\myoreclient\instantclient_12_1を設定しています。

    1. Windowsの「コントロール・パネル」で「システム」を選択します。

    2. 「システムの詳細設定」をクリックします。

    3. 「詳細設定」タブで、「環境変数」をクリックします。

    4. 「システム環境変数」OCI_LIB64が存在しない場合は作成します。OCI_LIB64の値にc:\oreclient\instantclient_12_1を設定します。

    5. 「システム環境変数」PATHを編集してc:\oreclient\instantclient_12_1を含めます。


      注意:

      環境変数を作成するグラフィカル・ユーザー・インタフェースは、Windowsのバージョンによってわずかに異なる場合があります。

A.3.3 Oracle R Enterprise Client Packagesのインストール

次の手順に従って、Oracle R Enterprise Client Packagesをダウンロードおよびインストールします。

Oracle R Enterprise Client Packagesをダウンロードするには、次の手順を実行します。

  1. Oracle Technology NetworkのOracle R Enterprise Downloadsページに移動します。

    http://www.oracle.com/technetwork/database/options/advanced-analytics/r-enterprise/ore-downloads-1502823.html

  2. ライセンス契約に同意します。

  3. 「Oracle R Enterprise Client Packages for Windows Platform」を選択します。ファイルを、第A.3.2項で作成したインストール・ディレクトリに保存します。

    c:\myoreclient\ore-client-win-x86_64-1.4.zip
    
  4. ファイルを解凍します。

    ファイルを解凍すると、clientサブディレクトリが作成されます。インストール・ディレクトリの内容は、次のように表示されます。

    ORE_1.4.zip
    OREbase_1.4.zip
    OREcommon_1.4.zip
    OREdm_1.4.zip
    OREeda_1.4.zip
    OREembed_1.4.zip
    OREgraphics_1.4.zip
    OREpredict_1.4.zip
    OREstats_1.4.zip
    ORExml_1.4.zip
    

RコンソールからOracle R Enterprise Client Packagesをインストールするには、次の手順を実行します。

  1. Windowsの「スタート」メニューからRを起動します。32ビット版および64ビット版Rの両方をインストールしている場合は、64ビット版Rを選択してください。

    例A-1で示したように、Rコンソールのウィンドウが表示されます。

  2. 次に示すようにパッケージをインストールします。

    install.packages("c:/myoreclient/client/ORE_1.4.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREbase_1.4.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREcommon_1.4.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREdm_1.4.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREeda_1.4.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREembed_1.4.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREgraphics_1.4.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREpredict_1.4.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREstats_1.4.zip", repos=NULL)
    install.packages("c:/myoreclient/client/ORExml_1.4.zip", repos=NULL)
    

    各パッケージのインストールが正常に完了するごとに、次のメッセージがRコンソールに表示されます。

    package 'package_name' successfully unpacked and MD5 sums checked
    

A.3.4 Oracle R Enterprise Supporting Packagesのインストール

次の手順に従って、Oracle R Enterprise Supporting Packagesをダウンロードおよびインストールします。

Oracle R Enterprise Supporting Packagesをダウンロードするには、次の手順を実行します。

  1. Oracle Technology NetworkのOracle R Enterprise Downloadsページに移動します。

    http://www.oracle.com/technetwork/database/options/advanced-analytics/r-enterprise/ore-downloads-1502823.html

  2. ライセンス契約に同意します。

  3. 「Oracle R Enterprise Supporting Packages for Windows Platform」を選択します。ファイルを、第A.3.2項で作成したインストール・ディレクトリに保存します。

    c:\myoreclient\ore-supporting-win-x86_64-1.4.zip
    
  4. ファイルを解凍します。

    ファイルを解凍すると、supportingサブディレクトリが作成されます。インストール・ディレクトリの内容は、次のように表示されます。

    cairo_1.5-5.zip
    DBI_0.2-7.zip
    png_0.1-7.zip
    ROracle_1.1-11.zip
    

Supporting PackagesをRコンソールからインストールするには、次の手順を実行します。

  1. Windowsの「スタート」メニューからRを起動します。32ビット版および64ビット版Rの両方をインストールしている場合は、64ビット版Rを選択してください。

    例A-1で示したように、Rコンソールのウィンドウが表示されます。

  2. 次に示すようにパッケージをインストールします。

    install.packages("c:/myoreclient/supporting/DBI_0.2-7.zip", repos=NULL)
    install.packages("c:/myoreclient/supporting/ROracle_1.1-11.zip", repos=NULL)
    install.packages("c:/myoreclient/supporting/png_0.1-7.zip", repos=NULL)
    install.packages("c:/myoreclient/supporting/cairo_1.5-5.zip", repos=NULL)
    

    各パッケージのインストールが正常に完了するごとに、次のメッセージがRコンソールに表示されます。

    package 'package_name' successfully unpacked and MD5 sums checked
    

A.3.4.1 Oracle R Enterprise Clientのインストール・ディレクトリ

すべてのクライアント・コンポーネントをインストールした後のクライアントのインストール・ディレクトリの構造は次のとおりです。

myoreclient
  client
  instantclient_12_1
  supporting

A.4 Oracle R Enterpriseのインストールの検証

Oracle R Enterpriseの基本的な機能が動作していることを確認するには、Oracle R Enterprise Serverへの接続を確立して、基本的なコマンドをいくつか実行してOracle R Enterpriseのデモ・プログラムの一部を実行します。


注意:

Oracle R Enterpriseを起動および使用するには、ユーザーIDにOracle R Enterpriseのインストールに必要とされる権限が必要です。詳細は、第4.2.3項「ユーザー要件」を参照してください。

例A-1 Oracle R Enterprise Serverへの接続

Oracle R Enterprise ClientをOracle R Enterprise Serverに接続するには、次の手順を実行します。

  1. Windowsの「スタート」メニューでR x64 3.0.1を選択します。

    Rコンソールが表示されます。

    rgui1.gifの説明が続きます
    図rgui1.gifの説明

  2. 次のコマンドを入力してOracle R Enterpriseを起動します。

    > library(ORE)
    
  3. 次のコマンドを入力してOracle R Enterprise Serverに接続します。次の例では、ユーザーrquserをサーバー・ホストserv1上のデータベースorclに、ポート1521を使用して接続しています。

    >  ore.connect(user="rquser", sid="orcl", host="serv1", password="rquserpsw",
                   port=1521, all=TRUE)
    Loading required package: ROracle
    Loading required package: DBI
    
  4. ore.is.connectedを実行して接続を確認します。接続が正常に確立されている場合は、コマンドによってTRUEが返されます。

    > ore.is.connected()
    [1] TRUE
    

例A-2 RQUSERからアクセスできるデータベース表のリスト

ore.lsコマンドで、現行ユーザーに利用可能なデータ・セットがリストされます。たとえば、TABLE1およびTABLE2rquserスキーマに存在している場合は、次のように表示されます。

> ore.ls()
[1] "TABLE1" "TABLE2"

例A-3 Rデータ・フレームのデータ表へのプッシュ

ore.pushコマンドで、Rデータ・フレームがデータ表に、またはデータ表がRデータ・フレームにプッシュされます。例:

  > cars <- ore.push(cars)

例A-4 埋込みR関数の実行

ore.doEvalコマンドで、データベース埋込みRエンジンの指定された関数の実行がスケジュール設定され、実行結果が返されます。

> ore.doEval(function() { 123 })
[1] 123

例A-5 Oracle R Enterpriseのデモ・スクリプトのリスト

Oracle R Enterpriseのデモ・スクリプトは$ORACLE_HOME/R/library/ORE/demoにあります。demoで、利用可能なデモのリストが表示されます。

> 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
freqanalysis                 Frequency cross tabulations
glm                          Generalized Linear Models
graphics                     Demonstrates visual analysis
group_apply                  Embedded R processing by group
hypothesis                   Hyphothesis testing functions
matrix                       Matrix related operations
nulls                        Handling of NULL in SQL vs. NA in R
odm_ai                       Oracle Data Mining: attribute importance
odm_dt                       Oracle Data Mining: decision trees
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_svm                      Oracle Data Mining: support vector machines
push_pull                    RDBMS <-> R data transfer
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
sql_like                     Mapping of R to SQL commands
stepwise                     Stepwise OLS linear regression
summary                      Summary functionality
table_apply                  Embedded R processing of entire table

A.4.1 Oracle R Enterpriseのデモ・スクリプトの実行

Oracle R Enterpriseのデモ・スクリプトの一部を実行することにより、インストールが正常に完了したことをさらに確認できます。エラーが発生せずスクリプトが完了した場合、デモは正常に実行されています。

例A-6 aggregateデモの実行

次の例では、aggregateデモが出力の一部を含めて表示されています。

> demo("aggregate", package="ORE")
 
        demo(aggregate)
        ---- ~~~~~~~~~
 
Type  <Return>   to start : 
 
> #
> #     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
> #
> #     Name: aggregate.R
> #     Description: Demonstrates aggregations
> #     See also summary.R
> #
> #
> #
> 
> ## Set page width
> options(width = 80)
 
> # Push the built-in iris data frame to the database
> IRIS_TABLE <- ore.push(iris)
 
> # Display the class of IRIS_TABLE 
> class(IRIS_TABLE)
[1] "ore.frame"
attr(,"package")
[1] "OREbase"
 
> # Select count(Petal.Length) group by species
> x = aggregate(IRIS_TABLE$Petal.Length,
+               by = list(species = IRIS_TABLE$Species),
+               FUN = length)
 
> class(x)
[1] "ore.frame"
attr(,"package")
[1] "OREbase"
.
.
.
. 

例A-7 row_applyデモの実行

次の例では、row_applyデモが出力の一部を含めて表示されています。

> demo("row_apply", package="ORE")
 
        demo(row_apply)
        ---- ~~~~~~~~~
 
Type  <Return>   to start : 
 
> #
> #     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
> #
> #     Name: row_apply.R
> #     Description: Execute R code on each row
> #
> #
> 
> ## Set page width
> options(width = 80)
 
> # Push the built-in iris data frame to the database
> IRIS_TABLE <- ore.push(iris)
 
> # Display the class of IRIS_TABLE 
> class(IRIS_TABLE)
[1] "ore.frame"
attr(,"package")
[1] "OREbase"
 
> # Apply given R function to each row
> ore.rowApply(IRIS_TABLE,
+              function(dat) {
+                  # Any R code goes here. Operates on one row of IRIS_TABLE at
+                  # a time
+                  cbind(dat, dat$Petal.Length)
+              })
$`1`
  Sepal.Length Sepal.Width Petal.Length Petal.Width   Species dat$Petal.Length
1          6.4         2.8          5.6         2.1 virginica              5.6
 
$`2`
  Sepal.Length Sepal.Width Petal.Length Petal.Width   Species dat$Petal.Length
1          7.2           3          5.8         1.6 virginica              5.8
 
$`3`
  Sepal.Length Sepal.Width Petal.Length Petal.Width   Species dat$Petal.Length
1          7.4         2.8          6.1         1.9 virginica              6.1
 
$`4`
  Sepal.Length Sepal.Width Petal.Length Petal.Width   Species dat$Petal.Length
1          7.9         3.8          6.4           2 virginica              6.4
 
$`5`
  Sepal.Length Sepal.Width Petal.Length Petal.Width   Species dat$Petal.Length
1          6.4         2.8          5.6         2.2 virginica              5.6
 
$`6`
.
.
.
.

例A-8 corデモの実行

次の例では、corデモが出力の一部を含めて表示されています。

> demo ("cor")
 
        demo(cor)
        ---- ~~~
 
Type  <Return>   to start : 
 
> #
> #     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
> #
> #     Name: cor.R
> #     Description: Correlation matrix
> #
> #
> #
> 
> ## Set page width
> options(width = 80)
 
> # Push the built-in iris data frame to the database
> IRIS_TABLE <- ore.push(iris)
 
> # Display the class of IRIS_TABLE 
> class(IRIS_TABLE)
[1] "ore.frame"
attr(,"package")
[1] "OREbase"
 
> # Remove non numeric columns
> iris_numeric = IRIS_TABLE[, c("Sepal.Length", "Sepal.Width",
+                               "Petal.Length", "Petal.Width")]
 
> # Pearson's correlation matrix
> cor(iris_numeric, use = "all.obs")
             Sepal.Length Sepal.Width Petal.Length Petal.Width
Sepal.Length    1.0000000  -0.1175698    0.8717538   0.8179411
Sepal.Width    -0.1175698   1.0000000   -0.4284401  -0.3661259
Petal.Length    0.8717538  -0.4284401    1.0000000   0.9628654
Petal.Width     0.8179411  -0.3661259    0.9628654   1.0000000
.
.
.
.

Warning messages:
1: ORE object has no unique key - using random order 
2: ORE object has no unique key - using random order 
3: ORE object has no unique key - using random order 
4: ORE object has no unique key - using random order 

例A-9 stepwiseデモの実行

次の例では、stepwiseデモが出力の一部を含めて表示されています。

> demo("stepwise")
 
        demo(stepwise)
        ---- ~~~~~~~~
 
Type  <Return>   to start : 
 
> #
> #     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
> #
> #     Name: stepwise.R
> #     Description: STEPWISE Multivariate Regression
> #
> #
> #
> 
> ## Set page width
> options(width = 80)
 
> # Push the built-in iris data frame to the database
> IRIS_TABLE <- ore.push(iris)
 
> # Display the class of IRIS_TABLE
> class(IRIS_TABLE)
[1] "ore.frame"
attr(,"package")
[1] "OREbase"
 
> # Let us first project out the non numeric columns
> IRIS_TABLE = IRIS_TABLE[, c("Sepal.Length", "Sepal.Width",
+                             "Petal.Length", "Petal.Width")]
 
> # Predict Sepal.Length based on the other 3 numeric columns
> # Do it stepwise
> model = ore.lm(Sepal.Length ~ ., data = IRIS_TABLE)
 
> model
 
Call:
ore.lm(formula = Sepal.Length ~ ., data = IRIS_TABLE)
 
Coefficients:
 (Intercept)   Sepal.Width  Petal.Length   Petal.Width  
      1.8560        0.6508        0.7091       -0.5565 
.
.
.