プライマリ・コンテンツに移動
Oracle® R Enterpriseユーザーズ・ガイド
リリース1.5
E67082-02
目次へ移動
目次
索引へ移動
索引

前
前へ
次
次へ

2.2.2.4 行名を使用した順序付け

例2-14に示すとおり、行名を使用してore.frameオブジェクトを順序付けできます。この例では、ローカルのRセッション・メモリーにdata.frameオブジェクトを作成し、それを記号aを付けてore.frameオブジェクト(Rセッションが接続されているOracle Databaseのメモリーにあります)にプッシュします。この例では、ore.frameオブジェクトにRのdata.frameオブジェクトのデフォルトの行名が付けられていることを示します。ore.frameが順序付けられているため、そこでrow.names関数を呼び出すと警告メッセージは生成されません。

この例では、例2-13ore.frameオブジェクトの順序付けられたSPAM_PKおよび順序付けられていないSPAM_NOPKを使用して、順序付けられていないSPAM_NOPKrow.namesを呼び出すと警告メッセージが生成されますが、順序付けられているSPAM_PKでは生成されないことを示します。

SPAM_PKオブジェクトは行名で順序付けられていて、この行名は|文字で区切られたTSとUSERID列値を組み合せた値です。この例では、行名を変更できることを示します。

例2-14 行名を使用した順序付け

# Create an ordered ore.frame by default.
a <- ore.push(data.frame(a=c(1:10,10:1), b=letters[c(1:10,10:1)]))
# Display the values in the b column. Note that because the ore.frame is
# ordered, no warnings appear.
a$b
# Display the default row names for the first six rows of the a column.
row.names(head(a))
# SPAM_NOPK has no unique key, so row.names raises error messages.
row.names(head(SPAM_NOPK))
# Row names consist of TS ‘|' USERID.
# For display on this page, only the first four row names are shown.
row.names(head(SPAM_PK))
# Reassign the row names to the TS column only
row.names(SPAM_PK) <- SPAM_PK$TS
# The row names now correspond to the TS values only.
row.names(head(SPAM_PK[,1:4]))
head(SPAM_PK[,1:4])
例2-14のリスト
R> # Create an ordered ore.frame by default.
R> a <- ore.push(data.frame(a=c(1:10,10:1), b=letters[c(1:10,10:1)]))
R> # Display the values in the b column. Note that because the ore.frame is
R> # ordered, no warnings appear.
R> a$b
 [1] a b c d e f g h i j j i h g f e d c b aLevels: a b c d e f g h i j
R> # Display the default row names for the first six rows of the a column.
R> row.names(head(a))
[1] 1 2 3 4 5 6
R> # SPAM_NOPK has no unique key, so row.names raises error messages.
R> row.names(head(SPAM_NOPK))
Error: ORE object has no unique key
In addition: Warning message:
ORE object has no unique key - using random order
R> # Row names consist of TS ‘|' USERID.
R> # For display on this page, only the first four row names are shown.
R> row.names(head(SPAM_PK))
        1001|351         1002|351         1003|352         1004|352
"1001|3.51E+002" "1002|3.51E+002" "1003|3.52E+002" "1004|3.52E+002"
R> # Reassign the row names to the TS column only
R> row.names(SPAM_PK) <- SPAM_PK$TS
R> # The row names now correspond to the TS values only.
R> row.names(head(SPAM_PK[,1:4]))
[1] 1001 1002 1003 1004 1005 1006
R> head(SPAM_PK[,1:4])
       TS USERID make address
1001 1001    351 0.00    0.64
1002 1002    351 0.21    0.28
1003 1003    352 0.06    0.00
1004 1004    352 0.00    0.00
1005 1005    353 0.00    0.00
1006 1006    353 0.00    0.00