Re: [R] Why a multi column, tab delimited file has only one column after reading in with read.table specification sep="\t"

From: Charles C. Berry <cberry_at_tajo.ucsd.edu>
Date: Sun, 20 May 2007 15:33:53 -0700

On Sun, 20 May 2007, Yong Wang wrote:

> Dear all:
> I have a tab delimited file as following

Probably you do NOT have a tab delimited file after all.

>
> AGE WEIGHT PROTEIN ........
> 6 20 3 ........
> 8 39 4 ........
>
> I tried to read it as following:
>
> data <- read.table(file,sep="\t",header=T);
>

What do

         table( count.fields( file ) )

and

         table( count.fields( file, sep='\t' ) )

tell you?

If the former gives the right number of fields, then you have white space without tabs separating the data elements.

If they both tell you that you have only one filed in each line, your lines quoted, perhaps.

Otherwise, can you "provide commented, minimal, self-contained, reproducible code" as requested below to demonstrate this behavior??

> but there is only column for the data after reading in,:
>
> dim(data);
> [1] 200 1
>
> the column name is "AGE...WEIGHT...........PROTEIN...."
>
>
> Any quick suggestion will be appreciated.
>
> Best Regards
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry                        (858) 534-2098
                                          Dept of Family/Preventive Medicine
E mailto:cberry_at_tajo.ucsd.edu	         UC San Diego
http://biostat.ucsd.edu/~cberry/         La Jolla, San Diego 92093-0901

______________________________________________
R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 20 May 2007 - 22:34:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 21 May 2007 - 01:31:19 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.