Re: [R] Help on read in a txt file

From: jim holtman <jholtman_at_gmail.com>
Date: Thu, 24 Apr 2008 21:27:09 -0400

It seems to indicate that you don't have 592 columns on all lines. Try the following to see how many columns are in each line:

x <- count.fields("A.txt", sep="\t")
which(x != 592) # print out the lines that are not correct

You might also try:

read.table("a.txt", sep="\t", fill=TRUE)

On Thu, Apr 24, 2008 at 8:32 PM, ss <affysnp_at_gmail.com> wrote:
> Dear list,
>
> Hello! I had a problem of reading in a txt file and need your help.
> The txt file, called A, comprises of 592 columns and 34179 rows.
> I need to note that for some cells of A , A[i,j], are blank.
>
> I used read.table() and got the warning message:
>
> > A<-read.table(file="A.txt",sep="\t")
> Warning message:
> In scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
> number of items read is not a multiple of the number of columns
> > dim(A)
> [1] 33623 592
>
> However, as some rows were missed because the original number
> of rows is 34179, after read.table(), it was decreased to 33623.
> I have no idea whether it has anything to do with the warning message.
>
> Do you have any suggestions for this problem?
>
> Thanks much,
> Alex
>
> [[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.
>

-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

______________________________________________
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.
Received on Fri 25 Apr 2008 - 01:34:21 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 Fri 25 Apr 2008 - 03:30:30 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.

list of date sections of archive