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

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon May 21 00:31:24 CEST 2007


Yong Wang wrote:
> Dear all:
> I have a tab delimited file as following
>
> AGE WEIGHT    PROTEIN   ........
> 6	20	3	........
> 8	39	4	........
>
> I tried to read it as following:
>
>  data <- read.table(file,sep="\t",header=T);
>
> 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.
>
>   
The most obvious guess is that your file is not really TAB delimited, 
but have columns separated by whitespace, i.e. a number of blanks. Some 
text editors or emailers will convert one into the other.



More information about the R-help mailing list