[R] read.table and newline

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Wed Jun 13 16:10:38 CEST 2001


Andrea Peters <Peters.Andrea at imbe.imed.uni-erlangen.de> writes:

> Hi,
> yesterday I installed the current R-devel and now I get
> the following warning message for program codes which made no
> problems under version R-1.2.3: 
> 
> Example:
> R> read.table("test.dat")
> Warning message: 
> incomplete final line in: readLines(con, n, ok)
>  
> where `test.dat' looks like
> 
> peters at artemis:~ > cat test.dat 
> 1 2 3peters at artemis:~ > 
> 
> i.e. without a newline at the end. 
> 
> The warning can be suppressed if the last line in "test.dat" ends with
> "\n". Is there a reason why "test.dat" should end with "\n" or is this a
> bug in R-devel?   

It's the normal convention for text files on Unix et al. that each
line is terminated with a \n. Not having one could be a sign that the
file was corrupted, hence the warning. Other utilities will also give
warnings, e.g. vim will display the file with "[noeol]", other vi-s
will complain and fix the last line.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list