5.3.1.1 列の選択例
OREdplyr
パッケージのselect
およびrename
関数の例。
例5-70 列の選択
次の例では、iris data.frame
オブジェクトでore.push
関数を使用して作成されるIRIS ore.frame
オブジェクトの列を選択します。
IRIS <- ore.push(iris)
# Select the specified column
names(select(IRIS, Petal.Length))
names(select(IRIS, petal_length = Petal.Length))
# Drop the specified column
names(select(IRIS, -Petal.Length))
# rename() keeps all variables
names(rename(IRIS, petal_length = Petal.Length))
この例のリスト
R> IRIS <- ore.push(iris)
R> # Select the specified column
R> names(select(IRIS, Petal.Length))
[1] "Petal.Length"
R> names(select(IRIS, petal_length = Petal.Length))
[1] "petal_length"
R>
R> # Drop the specified column
R> names(select(IRIS, -Petal.Length))
[1] "Sepal.Length" "Sepal.Width" "Petal.Width" "Species"
R>
R> # rename() keeps all variables
R> names(rename(IRIS, petal_length = Petal.Length))
[1] "Sepal.Length" "Sepal.Width" "petal_length" "Petal.Width" "Species"
親トピック: データの選択および順序付け