[R] reading in a file with multiple data types
Prof Brian Ripley
ripley at stats.ox.ac.uk
Sun Sep 14 21:11:40 CEST 2003
You need to use connections to read block by block.
On Sun, 14 Sep 2003, Siew Leng TENG wrote:
> Hi,
>
> I have a data file which contains multiple data types
> (char and numeric) alongside with line spaces, tabs
> and spaces. I hope to extract out the numeric blocks
> of the data, probably as matrices or dataframes where
> each line in the data block is a corresponding row in
> the dataframe/ matrix.
>
> I have tried using many R read functions but they do
> not seem to yield the appropriate structure that
> allows the extraction of the numeric blocks correctly
> (due to the line spaces, tabs and spaces).
>
> I gratefully appreciate any advice and suggestion on
> how to obtain the desired data matrices/ dataframes
> from this data file in R.
>
> Thank you,
> Siew-Leng
> *Using R1.7.1. on windows ME, and on Unix.
>
> ------------------------------------
> My data file contains data in the following block
> structure :
>
> 1) block of a summary (char)
> 2) line spaces
> 3) text line
> 4) Data : stored as :
> number \t number (spc) number (spc) number (spc) ...
> and so on.
> [the number of numeric values stored at this line is
> not fixed]
> 5) same structure from 2 - 4
>
> An example of my data (in exact format) is given below
> :
>
>
> Final results
> Final value 75.162993
> First case value 11
> First case value 10
> Case indices
> 3 4 1 5 6 7 8 9 10 11
>
> Estimates :
> 8.875350
> 3.894280
> 7.972684
> 4.934348
> 0.012406
> 0.002134
> -0.024216
> 0.072946
> -0.000468
> 0.042769
> -0.126641
>
> Final components :
> 3 0 2 2
>
> 4 0 1
>
> 1
>
> 5 0 0 0 1 2
>
> 6 1 1 1 1 1 1
>
> 7 1 1 1 1 1
>
> 8 1 1 1 1
>
> 9 0 0 0 0 1 1 2
>
> 10 2 2
>
> 11 0 2
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list