パッケージを使用して、Hmisc
2 つの連続変数の分位数を計算し、結果をクロステーブルで比較しています。以下に私のコードがあります。
私の問題は、観測数が増えると分位数の計算にかなりの時間がかかることです。
やその他のパッケージを使用してdata.table
、この手順を高速化する可能性はありますか?ddply
ありがとう。
library(Hmisc)
# Set seed
set.seed(123)
# Generate some data
a <- sample(1:25, 1e7, replace=TRUE)
b <- sample(1:25, 1e7, replace=TRUE)
c <- data.frame(a,b)
# Calculate quantiles
c$a.quantile <- cut2(a, g=5)
c$b.quantile <- cut2(b, g=5)
# Output some descriptives
summaryM(a.quantile ~ b.quantile, data=c, overall=TRUE)
# Time spent for calculation:
# User System verstrichen
# 25.13 3.47 28.73