[R] Loading 'akward' data file
andy_liaw at merck.com
Wed Jun 16 14:31:27 CEST 2004
Generally you'd use file() to open the file, then use readLines(), say
inside a while() loop to read one `chunk' at a time. However, your example
looks a bit strange. The possibility of empty line makes it a bit more
complicated, by that last couple of lines seems to suggest that you could
have a line of data follow by another line of data without variable label.
If that's true, I don't know how you would parse the file...
> From: Iago Mosqueira
> I need to load a somehow diffilcult data file. It has lines with
> variable names followed by a variable number of rows and columns of
> data, separated from the next variable sometimes by a blank line,
> sometimes simply by the new variable name. For example:
> What would be the best startegy for loading a file like this? I would
> like to have it staored as a list with the variable names used to name
> the slots. Any pointers?
> Many thanks,
> Iago Mosqueira
> Unidad de Investigacin Marina
> Marine Research Division
> AZTI Fundazioa
> Txatxarramendi Ugartea z/g
> 48395 Sukarrieta, Bizkaia
> Tfno. +(34) 94 602 94 00
> Fax +(34) 94 602 94 01
> email imosqueira at suk.azti.es
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide!
More information about the R-help