Skip to content

Non-standard characters in Ascii-Files

1 message · Schneider, Manuel

#
Dear Henrik, dear Peter

many thanks for your reply. I've now done tests on other computers and yes, this is a local problem on my computer. Unfortunately, my second HD produces the same flaw so it must be the disk controller or whatever. When correcting the files with vedit, the non-standard characters sometimes seem to jump around to other places. Funny bug, but definitely nothing to do with R.

Best regards

Manuel

-----Urspr??ngliche Nachricht-----
Von: Henrik Bengtsson [mailto:hb at maths.lth.se] 
Gesendet: Montag, 29. August 2005 15:43
An: Peter Dalgaard
Cc: Schneider, Manuel; r-help at stat.math.ethz.ch
Betreff: Re: [R] Non-standard characters in Ascii-Files
Peter Dalgaard wrote:
and on my R v2.1.1 patched (2005-08-25) on WinXP Pro SP2 (sic!), I get

 > temp<-matrix(c(1:16000000),4000,4000)
 > write(file="temp.txt", temp)
 > file.info("temp.txt")$size
[1] 136088897
 > rm(temp)
 > dummy <- scan("temp.txt")
Read 16000000 items
I second this, check the file with an external application or try the 
following ad-hoc code:

zcan <- function(filename) {
   fh <- file(filename, open="r");
   on.exit(close(fh));
   count <- 0;
   while(TRUE) {
     s <- readChar(fh, n=1024);
     if (nchar(s) == 0)
       break;
     count <- count + nchar(s);
     if (gsub("[\n 0-9]*", "", s) != "")
       stop("Error after reading ", count, " characters: ", s);
   }
}

Cheers

Henrik