Reading binary file into R

本小妞迷上赌 提交于 2019-12-01 06:22:23

You could open the file as a raw file, then issue readBin or readChar commands to get each line. Append each value to a column as you go.

my.file <- file('path', 'rb')

id <- integer(0)
response <- character(0)
...

Loop around this block:

id = c(id, readBin(my.file, integer(), size = 4, endian = 'little'))
response = c(response, readChar(my.file, 1))
...
readChar(my.file, size = 1) # For UNIX newlines.  Use size = 2 for Windows newlines.

Then create your data frame.

See here: http://www.ats.ucla.edu/stat/r/faq/read_binary.htm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!