Dear all, I have a file with some sequence (seq.txt). I am writting following code and getting error! Can please help me? seqfile<-read.table(file="seq.txt") Warning message: In read.table(file = "seq.txt") : incomplete final line found by readTableHeader on 'seq.txt' Thanks in advance Albert -------------- next part -------------- NNNNNNNNNNATTAAAGGGC
albert coster <albertcoster2010 <at> gmail.com> writes:> > Dear all, > > I have a file with some sequence (seq.txt). I am writting following code and > getting error! Can please help me? > > seqfile<-read.table(file="seq.txt") > Warning message: > In read.table(file = "seq.txt") : > incomplete final line found by readTableHeader on 'seq.txt' > > Thanks in advance > > AlbertVery hard to say without more details. Please provide a reproducible example, or at least more information. That is not an error, it's a warning: it means there *might* be something wrong with your data file, but not necessarily. Have you inspected the results? Are they what you expected? If not, do they give you some more information about what might be wrong? Usual suspects: check for unterminated/single quotation marks in your file.
albert coster wrote:> > Dear all, > > I have a file with some sequence (seq.txt). I am writting following code > and > getting error! Can please help me? > > > seqfile<-read.table(file="seq.txt") > Warning message: > In read.table(file = "seq.txt") : > incomplete final line found by readTableHeader on 'seq.txt' >The message is a warning not an error. It means that the last line of your file does not end with a line-ending sequence. Such as carriage return/linefeed (\r\n) or a just a linefeed (\n). In your editor you either need to press <return> at the end of the last line or tell the editor to terminate the last line with a line-endng character. Berend -- View this message in context: http://r.789695.n4.nabble.com/problem-in-reading-a-sequence-file-tp3645717p3646214.html Sent from the R help mailing list archive at Nabble.com.
On Tue, Jul 05, 2011 at 04:53:32PM +0200, albert coster wrote: I'm taking this back to the list so others can follow up.> Yes, the file is consists of one string (sequence) per line. > > The files format is following: > > Sequence > NNNNNNNNNNATTAAAGGGCOK - in that case (and as you want a vector anyway) you can use scan('seq.txt', what=character)()> > > seqfile<-read.table("seq.txt") > Warning message: > In read.table("seq.txt") : > incomplete final line found by readTableHeader on 'seq.txt'OK - that means you don't have a newline ('\n') at the end of your sequence file and read.table is warning you about that.> > str(seqfile) > 'data.frame': 2 obs. of 1 variable: > $ V1: Factor w/ 2 levels "NNNNNNNNNNATTAAAGGGC",..: 2 1This indicates that there are at least two lines in the file (so you got two levels in the factor). So I would guess there is an empy line before your sequence or you really have the word 'Sequence' on line 1. For sequence data it probably does not make much sense to let R convert to factor and a character colunm would be prefered. This can be accomplished by using one of the options 'as.is', 'stringsAsFactors' or 'colClasses'. If you use scan you'll need to get rid of the extra line first. If you stick with read.table you can specify the first line as your header line using the header=TRUE option. Now you can address column 'Sequence' as such. Example:> dat <- read.table('seq.txt', as.is=T, header=TRUE) > dat$Sequence[1] "NNNNNNNNNNATTAAAGGGC"> dat[, 'Sequence'][1] "NNNNNNNNNNATTAAAGGGC"> str(dat)'data.frame': 1 obs. of 1 variable: $ Sequence: chr "NNNNNNNNNNATTAAAGGGC" cu Philipp -- Dr. Philipp Pagel Lehrstuhl f?r Genomorientierte Bioinformatik Technische Universit?t M?nchen Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/