Probelm with read.table
On 11 Dec 2003 at 9:55, Andy Bunn wrote:
But why comment.char="V"? Nobody said there need to be a comment.char. More natural (and faster for large files) is comment.char="" Kjetil Halvorsen
You need to change the comment character from #. This works for me: $ mydf <- read.table(file="mytextfile.txt", header = T, sep="\t",na.strings="#N/A", comment.char = "V") $ mydf X738307 X527178 X714456 X557955 1 NA 17.42 6.22 4.73 2 NA 17.30 6.23 4.75 3 NA 17.29 6.17 4.70 4 NA 17.07 6.12 4.60 5 NA 17.27 6.19 4.70 6 NA 17.72 6.40 4.78 7 NA 17.12 6.19 4.75 8 NA 17.07 6.15 4.65 9 NA 17.03 6.07 4.64 10 NA 17.38 6.13 4.70 11 NA 17.38 6.13 4.70 12 NA 17.38 6.13 4.70 13 NA 17.38 6.13 4.70 14 NA 17.34 6.28 4.70 15 10 17.57 6.33 4.75 16 11 17.57 6.33 4.75 17 12 17.57 6.33 4.75 18 13 17.39 6.25 4.87 19 14 17.15 6.33 5.06 20 15 17.05 6.21 5.00 21 16 16.87 6.14 5.15 22 17 16.72 6.27 5.23 HTH, Andy -----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Arnaud_Amsellem at ssga.com Sent: Thursday, December 11, 2003 3:31 AM To: r-help at stat.math.ethz.ch Subject: [R] Probelm with read.table Hi All, I have the following text file (mytextfile.txt) 738307 527178 714456 557955 #N/A 17.42 6.22 4.73 #N/A 17.3 6.23 4.75 #N/A 17.29 6.17 4.7 #N/A 17.07 6.12 4.6 #N/A 17.27 6.19 4.7 #N/A 17.72 6.4 4.78 #N/A 17.12 6.19 4.75 #N/A 17.07 6.15 4.65 #N/A 17.03 6.07 4.64 #N/A 17.38 6.13 4.7 #N/A 17.38 6.13 4.7 #N/A 17.38 6.13 4.7 #N/A 17.38 6.13 4.7 #N/A 17.34 6.28 4.7 10 17.57 6.33 4.75 11 17.57 6.33 4.75 12 17.57 6.33 4.75 13 17.39 6.25 4.87 14 17.15 6.33 5.06 15 17.05 6.21 5 16 16.87 6.14 5.15 17 16.72 6.27 5.23 I use the following command: mydf <- read.table(file="mytextfile.txt", header = T, sep="\t",na.strings=" #NA") When the above command is applied I have only 8 lines in mydf. I tried many options but nothing seems to get me the entire file. If the #NA are not in the first column it seems to work fine i.e I get 22 lines in mydf. Anyone would know a way of getting the entire file even if #NA are in the first column? I use R 1.8.0 on Windows 2000 Any help appreciated Arno
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help