例3-6に示すとおり、aggregate関数を使用してデータを集計できます。この例では、irisデータセットをデータベース・メモリーにore.frameオブジェクトのiris_ofとしてプッシュします。length関数を使用して、iris_ofの値をSpecies列で集計します。その後、結果の最初の3行を表示します。
関連項目:
aggregate.Rのスクリプト例
例3-6 データの集計
# Create a temporary database table from the iris data set and get an ore.frame.
iris_of <- ore.push(iris)
aggdata <- aggregate(iris_of$Sepal.Length,
by = list(species = iris_of$Species),
FUN = length)
head(aggdata, 3)
例3-6のリスト# Create a temporary database table from the iris data set and get an ore.frame.
R> iris_of <- ore.push(iris)
R> aggdata <- aggregate(iris_of$Sepal.Length,
+ by = list(species = iris_of$Species),
+ FUN = length)
R> head(aggdata, 3)
species x
setosa setosa 50
versicolor versicolor 50
virginica virginica 50