Rで学ぶスケーラブルなデータ処理
Simon Urbanek
Member of R-Core, Lead Inventive Scientist, AT&T Labs Research
すべてのデータが処理されるまで1〜3を繰り返す
iotoolsパッケージでは、データの物理的な読み込みとRオブジェクトへの解析を分離することで、柔軟性とパフォーマンスを向上させています。
readAsRaw() はデータ全体を生ベクトルとして読み込むread.chunk() はデータをチャンク単位で生ベクトルとして読み込むmstrsplit() は生データを行列に変換するdstrsplit() は生データをデータフレームに変換するread.delim.raw() = readAsRaw() + dstrsplit()
# Open a file connection
fc <- file("data-file.csv", "rb")
# Read the first line if the data has a header
readLines(fc, n = 1)
....
# Code to import and parse the data
....
# Close the file connection
close(fc)
Rで学ぶスケーラブルなデータ処理