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

前
 
次
 

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

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


注意:

この付録では、Oracle R Enterpriseの初期インストールについて説明します。クライアントまたはサーバーにOracle R Enterpriseコンポーネントがすでに存在する場合、第7.1項「Oracle R Enterpriseのアップグレード」を参照してください。

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. 環境の確認

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

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

A.2.1 環境の確認

表A-1 Oracle R Enterprise Serverの要件のチェックリスト

質問 回答例

Linuxバージョンは何ですか。

% cat /etc/*-release
Enterprise Linux Server release 5.6 

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

ブラウザを起動します。

rootでログインできますか。

% sudo -s
Password: ---------
#
# exit
%              

Oracle Databaseはインストールされていますか。

% SQLPLUS / as sysdba
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bitProduction
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
> exit
%

$ORACLE_HOMEの値は何ですか。

% echo $ORACLE_HOME
/myhome/product/12.1.0.1/dbhome_1

$ORACLE_SIDの値は何ですか。

% echo $ORACLE_SID
orcl

$LD_LIBRARY_PATH$ORACLE_HOME/libが含まれていますか。

% echo $LD_LIBRARY_PATH
/myhome/product/12.1.0.1/dbhome_1/lib:....

$PATH$ORACLE_HOME/binが含まれていますか。

% echo $PATH
/myhome/product/12.1.0.1/dbhome_1/bin:.......

dbaグループのメンバーですか。

% groups
g102 dba

$ORACLE_HOME/libに書込みできますか。

% ls -ld $ORACLE_HOME/lib
drwxr-xr-x 3 myuser g102 12288 Jan 27 15:31
/myhome/product/12.1.0.1/dbhome_1/lib/ ...

A.2.2 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
    
  5. rootユーザーを終了します。

    exit
    

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

Oracle R Enterprise Serverには、Oracle Databaseのrqsysスキーマと、Oracle R Enterpriseパッケージおよび共有ライブラリが含まれます。

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

  1. 表A-1「Oracle R Enterprise Serverの要件のチェックリスト」に従って、環境を確認します。

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

    /myhome/myoreserver/
    
  3. Oracle Technology NetworkのOracle R Enterpriseのダウンロード・ページから、Oracle R Enterprise Serverインストール・ファイルおよびSupporting Packagesをダウンロードします。

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

    1. ライセンス契約に同意して、ご使用のプラットフォーム用のOracle R Enterprise Serverファイルをインストール・ディレクトリにダウンロードします。

    2. ライセンス契約に同意して、ご使用のプラットフォーム用のOracle R Enterprise Supporting Packagesをインストール・ディレクトリにダウンロードします。

    インストール・ディレクトリに2つのzipファイルが配置されます。

    ore-server-linux-x86-64-1.4.1.zip
    ore-supporting-linux-x86-64-1.4.1.zip
    
  4. ファイルを解凍します。

    unzip ore-server-linux-x86-64-1.4.1.zip
    unzip ore-supporting-linux-x86-64-1.4.1.zip
    

    両方のファイルを解凍した後のインストール・ディレクトリは次のようになります。

    /myhome/myoreserver
         ore-server-linux-x86-64-1.4.1.zip
         ore-supporting-linux-x86-64-1.4.1.zip
         server.sh
         /server
         /supporting
    
  5. 例A-1に示すように、server.shを実行して、Oracle R Enterprise Serverのデフォルト・インストールを実行します。スクリプトは対話的に実行されます。ユーザー入力は太字で表示されます。


    注意:

    スクリプトによりプロンプトに[list]と表示されたら、[Enter]を押すと、選択した使用可能なアイテムのリストが表示されます。

    例A-1 Oracle R Enterprise Serverのデフォルトの初回インストール

    ktaylor@adc2171704> ./server.sh -i
     
    Oracle R Enterprise 1.4.1 Server.
     
    Copyright (c) 2012, 2014 Oracle and/or its affiliates. All rights reserved.
     
    Checking platform .................. Pass
    Checking R ......................... Pass
    Checking R libraries ............... Pass
    Checking ORACLE_HOME ............... Pass
    Checking ORACLE_SID ................ Pass
    Checking sqlplus ................... Pass
    Checking ORACLE instance ........... Pass
    Checking CDB/PDB ................... Pass
    Checking ORE ....................... Pass
     
    Choosing RQSYS tablespaces
      PERMANENT tablespace to use for RQSYS [list]:
    EXAMPLE
    SYSAUX
    SYSTEM
    USERS
      PERMANENT tablespace to use for RQSYS [list]: SYSAUX
      TEMPORARY tablespace to use for RQSYS [list]:
    TEMP
      TEMPORARY tablespace to use for RQSYS [list]: TEMP
    Choosing RQSYS password
      Password to use for RQSYS: XXXXXXX
     
    Choosing ORE user
      ORE user to use [list]:
    BI
    HR
    IX
    OE
    SCOTT
    SH
      ORE user to use [list]: ruser2
    Choosing RUSER2 tablespaces
      PERMANENT tablespace to use for RUSER2 [list]: USERS
      TEMPORARY tablespace to use for RUSER2 [list]: TEMP
    Choosing RUSER2 password
      Password to use for RUSER2:
      
      
      Current configuration
      R Version ...................... Oracle Distribution of R version 3.0.1  (--)
      R_HOME ......................... /usr/lib64/R
      R_LIBS_USER .................... /product/12.1.0.1/dbhome_1/R/library
      ORACLE_HOME .................... /product/12.1.0.1/dbhome_1
      ORACLE_SID ..................... orcl
     
      Existing R Version ............. None
      Existing R_HOME ................ None
      Existing ORE data .............. None
      Existing ORE code .............. None
      Existing ORE libraries ......... None
     
      RQSYS PERMANENT tablespace ..... SYSAUX
      RQSYS TEMPORARY tablespace ..... TEMP
     
      ORE user type .................. New
      ORE user name .................. RUSER2
      ORE user PERMANENT tablespace ...USERS
      ORE user TEMPORARY tablespace .. TEMP
      Grant RQADMIN role ............. No
     
      Operation ........................ Install/Upgrade/Setup
     
    Proceed? [yes] y
     
    Removing R libraries ............... Pass
    Installing R libraries ............. Pass
    Installing ORE libraries ........... Pass
    Installing RQSYS data .............. Pass
    Configuring ORE .................... Pass
    Installing RQSYS code .............. Pass
    Installing ORE packages ............ Pass
    Creating ORE script ................ Pass
    Installing migration scripts ....... Pass
    Installing supporting packages ..... Pass
    Creating ORE user .................. Pass
    Granting ORE privileges ............ Pass
     
    Done
    

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

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

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

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

  2. Oracle Instant Clientのインストール

  3. Oracle R Enterpriseパッケージのインストール

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

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

Oracle R Distributionをインストールする前に、ご使用のMicrosoft Windowsのバージョンが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パッケージのインストール

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

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

  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. Windows用のClient Packagesを選択します。ファイルを、第A.3.2項で作成したインストール・ディレクトリに保存します。

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

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

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

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

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

    例A-2に示すようなRコンソールのウィンドウが表示されます。

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

    install.packages("c:/myoreclient/client/ORE_1.4.1.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREbase_1.4.1.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREcommon_1.4.1.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREdm_1.4.1.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREeda_1.4.1.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREembed_1.4.1.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREgraphics_1.4.1.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREmodels_1.4.1.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREpredict_1.4.1.zip", repos=NULL)
    install.packages("c:/myoreclient/client/OREstats_1.4.1.zip", repos=NULL)
    install.packages("c:/myoreclient/client/ORExml_1.4.1.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. ライセンス契約に同意し、Windows用のSupporting Packagesを選択します。ファイルを、第A.3.2項で作成したインストール・ディレクトリに保存します。

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

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

    arules_1.1-3.zip
    Cairo_1.5-5.zip
    DBI_0.2-7.zip
    png_0.1-7.zip
    ROracle_1.1-12.zip
    statmod_1.4.20.zip
    

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

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

    Rコンソール・ウィンドウが表示されます。

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

    install.packages("c:/myoreclient/supporting/ROracle_1.1-12.zip", repos=NULL)
    install.packages("c:/myoreclient/supporting/DBI_0.2-7.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)
    install.packages("c:/myoreclient/supporting/arules_1.1-3.zip", repos=NULL)
    install.packages("c:/myoreclient/supporting/statmod_1.4.20.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.3.3項「ユーザー要件」を参照してください。

例A-2 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-3 RQUSERからアクセスできるデータベース表のリスト

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

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

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

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

  > cars <- ore.push(cars)

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

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

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

例A-6 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-7 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-8 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-9 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-10 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 
.
.
.