R 的可擴展資料處理
Simon Urbanek
Member of R-Core, Lead Inventive Scientist, AT&T Labs Research
# 建立隨機向量
x <- rnorm(100)
# 求平均數
mean(x)
-0.01996644
# 對向量的區塊求和 sl <- Map(function(v) { c(sum(v), length(v))}, list(x[1:25], x[26:100])) # 加總各區塊的總和與長度 slr <- Reduce(`+`, sl) # 求平均數 slr[1]/slr[2]-0.01996644
需要一次讀入全部資料的運算,無法用 Split-Apply-Combine 計算。
例:中位數
許多迴歸流程可用 split-apply-combine 表示
R 的可擴展資料處理