[R] Variable length datafile import problem

John Kane jrkrideau at yahoo.ca
Tue Feb 15 18:03:55 CET 2011


Your example does not seem to accurately mirror your data since there are no variable column counts.

If the data is not confidential, it might be a good idea to load a sample of it somewhere were list readers can get it and examine the actual file layout.  [url=http://www.mediafire.com/][b]Mediafire[/b][/url] is a convenient place.

--- On Tue, 2/15/11, Ingo Reinhold <ingor at kth.se> wrote:

> From: Ingo Reinhold <ingor at kth.se>
> Subject: [R] Variable length datafile import problem
> To: "r-help at r-project.org" <r-help at r-project.org>
> Received: Tuesday, February 15, 2011, 9:12 AM
> Dear all,
> 
> I am stuck the reading of a file which has 100s of rows and
> variable column counts.
> 
> The tab-limited data file looks something like:
> 
> Some_Text     1    3 
>   123    1534    -119   
> 1010    178
> Some_Taxt     1    3 
>   133    1434    -219   
> 1010    178
> Some_Tsxt     1    3 
>   244    1334    -319   
> 1010    178
> Some_Tfxt     1    3 
>   153    1234    -419   
> 1010    178
> Some_Trxt     1    3 
>   163    1234    -519   
> 1010    178
> 
> When I try reading it using:
> 
> rawData=read.table("Datafile.dat", fill=FALSE, sep="\t",
> header=FALSE);
> 
> I get something like
> 
> Some_Text     1    3 
>   123    1534    -119   
> 1010    178
> Some_Taxt     1    3 
>   133    1434    -219   
> 1010    178
> 1010
> Some_Tsxt     1    3 
>   244    1334    -319   
> 1010    178
> Some_Tfxt     1    3 
>   153    1234    -419   
> 1010    178
> -419
> Some_Trxt     1    3 
>   163    1234    -519   
> 1010    178
> 
> I am not sure what this is. It also appear to be quenching
> some of the columns, which may be the problem. My current
> maximum is around 250, but this is not determined. When
> importing it the maximum table size seems to stop at 146.
> 
> Has anyone seen this before?
> 
> Many thanks,
> 
> Ingo
> 
>     [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org
> 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.
> 





More information about the R-help mailing list