Reading structured texts in R
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.
- Number of fields of each Block are fixed.
- A few fields might span several rows.
My questions are
- 开发者_运维知识库
- Use a list or a data frame to hold the file content?
- Is any other way to properly parse the file content other than readlines?
- 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.
精彩评论