R में Scalable Data Processing
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
ऐसे ऑपरेशंस जिन्हें एक साथ सारा डेटा चाहिए, उन्हें Split-Apply-Combine से नहीं निकाला जा सकता।
उदाहरण: Median
कई regression routines को split-apply-combine के रूप में लिखा जा सकता है
R में Scalable Data Processing