开发者

Reading structured texts in R

开发者 https://www.devze.com 2023-03-31 12:54 出处:网络
Please give me some advice on reading text files similar to the following one in R? Each block is surrounded by a header and a footer.

Please give me some advice on reading text files similar to the following one in R?

  1. Each block is surrounded by a header and a footer.
  2. Number of fields of each Block are fixed.
  3. A few fields might span several rows.

My questions are

    开发者_运维知识库
  1. Use a list or a data frame to hold the file content?
  2. Is any other way to properly parse the file content other than readlines?
  3. how to create an empty typed-vector?

Thanks in advance!


I assume you have read and looked at the many packages mentioned in R-data? Apart from that: from what I understand, you need a list of data.frames for your data (each block coinciding with one data.frame).

A better option may be to first split the file into several 'block'-files (preferably with tools outside of R, as these may be better fit for that particular task), and then read the data.frames with standard functions (assuming these comply - you do not give much information on that).

Why would you want to create an empty typed vector? Closest thing is probably a list. But if you think you need one, you may need to rethink.

0

精彩评论

暂无评论...
验证码 换一张
取 消