Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
size=2 のバイナリ ファイルがあります。しかし、すべてのデータをベクトルに読み込みたいのですが、このバイナリ データの全長を見つける方法がわかりません。
f <- file("a.bin", "rb") readBin(f, integer(), size = 2, n = ??)
使うだけ
file.info('a.bin')$size
を使用x <- scan("a.bin", raw())してファイル全体を生のベクトルに読み取り、次に を使用y <- readBin(x, integer(), n=length(x), size=2)して生のベクトルを変換します。
x <- scan("a.bin", raw())
y <- readBin(x, integer(), n=length(x), size=2)
生のベクトルの各要素は 4 バイトであるため、 の正しい値を計算するには、何らかの変換が必要になる場合がありますn。
n