R에서 확장 가능한 데이터 처리
Simon Urbanek
Member of R-Core, Lead Inventive Scientist, AT&T Labs Research
# Create a random vector
x <- rnorm(100)
# Find the mean
mean(x)
-0.01996644
# Take the sum of chunks of
# the vector
sl <- Map(function(v) {
c(sum(v), length(v))},
list(x[1:25], x[26:100]))
# Add the sums and lengths
slr <- Reduce(`+`, sl)
# Find the mean
slr[1]/slr[2]
-0.01996644
모든 데이터를 한 번에 필요로 하는 연산은 분할-적용-결합 방식으로 계산할 수 없습니다.
예시: 중앙값
많은 회귀 루틴은 분할-적용-결합 방식으로 작성할 수 있습니다.
R에서 확장 가능한 데이터 처리