Skip to content

reading "special" text files

3 messages · Jan M. Wiener, Uwe Ligges, Brian Ripley

#
hello,

assume you have a txt-file (sep="\t" or "") looking as follows that you 
want to read into a variable:

1	1	2			3
2	1	2	3		4
3	1	5	6	7	8

the result should look like this (e.g., in a data.frame):

1	1	2	3
2	1	2	3	4
3	1	5	6	7	8

is there any way to do so?

thanks in advance,
jan
#
Jan Wiener wrote:

            
Yes, with e.g. sep="\t" and sep=" " the number of separators is taken 
into account.
No, with sep="" the separator is *any* white space.


Uwe Ligges
#
On Wed, 24 Aug 2005, Jan Wiener wrote:

            
Into a variable or a data frame?
With no column names? Not possible.
I think we need to know what the structure here is.  At a guess, the 
separator is multiple tabs as in the example.  In that case
V1 V2 V3 V4 V5 V6
1  1  1  2  3 NA NA
2  2  1  2  3  4 NA
3  3  1  5  6  7  8

or
V2 V3 V4 V5 V6
1  1  2  3 NA NA
2  1  2  3  4 NA
3  1  5  6  7  8

does in essence what you want.