0

I have a question about R. If I havr a date like this

# name : Matrix
            col1.   col2
row1
row2

How can read the name of the subset of data from header and make a frame of same name in R. So that I can use it by the name Matrix.

And if I needed to read number of rows as specified in the header. What should I do. For example if this was the header, I would like to read 2 columns and 2 rows and name this frame Matrix

# name : Matrix
# row: 2
# col: 2
            col1.   col2
row1
row2

Thank you all.

jav321
  • 151
  • 2
  • 11
  • 2
    This isn't exactly [reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-e) but generally you could use `readLines()` to read some number of header lines and parse them yourself. Then you can use that information to read the rest of the data in the non-commented lines. But this format doesn't conform to any spec that I know if so you'll have to build all the parsing and creation logic yourself. Did you try anything at all yourself? Where did you get stuck? – MrFlick Dec 12 '17 at 20:26
  • 1
    Similar strategy here maybe: https://support.bioconductor.org/p/66724/ – MrFlick Dec 12 '17 at 20:29
  • 2
    Four steps: read all lines that could contain header information, use regex to extract `name`, `row`, and `column` into variables, read the table in as a matrix, then name/subset based on your stored values from the header. – Mako212 Dec 12 '17 at 20:36

0 Answers0