Hi! I want to read data (using read.table(.)) from a file like: "col1", "col2", "col3" 1, 1, 1 2, 2, 2 But the white spaces are interpreted: x <- read.table("filename", header=TRUE, sep=",") ## or read.csv(...) colnames(x) [1] "col1" " col2" " col3" ^ ^ So I would like to pass an argument like strip.white=TRUE (as in scan(.)) to read.table(.) . If this is nonsense, please let me know. At my first look only three lines (and documentation) must be changed: l. 1-3 add: function(..., strip.white=FALSE, ...) ^^^^^^^^^^^^^^^^^ l. 16 + 35 add: ... <- scan(..., strip.white=strip.white, ...) ^^^^^^^^^^^^^^^^^^^^^^^ There is also a little bug in the "windows help" to read.table(.): Usage read.table(file, header = FALSE, sep = "", dec = ".", quote = "'", ^^^ must be: "\"'" and both of read.csv(file, header = TRUE, sep = ",", quote="", read.csv2(file, header = TRUE, sep = ";", quote="", dec=",", ^^ must be: "\"" Looks like a general problem with a backslashes in "winhelp" (?). If requested, I will create a bug report... Regards, Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>Date: Wed, 31 May 2000 09:11:38 +0200 >From: Uwe Ligges <ligges@statistik.uni-dortmund.de> > >There is also a little bug in the "windows help" to read.table(.): > >Usage >read.table(file, header = FALSE, sep = "", dec = ".", quote = "'", > ^^^ must >be: "\"'" >and both of >read.csv(file, header = TRUE, sep = ",", quote="", > >read.csv2(file, header = TRUE, sep = ";", quote="", dec=",", > > ^^ must be: "\"" > >Looks like a general problem with a backslashes in "winhelp" (?).Which system of help, and if text help which pager? (I'm not on Windows here to check, but the text file looks fine on Unix. My guess is that this a pager bug.) -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Date: Wed, 31 May 2000 09:49:52 +0200 > From: Uwe Ligges <ligges@statistik.uni-dortmund.de> > X-Accept-Language: en > To: Prof Brian Ripley <ripley@stats.ox.ac.uk> > CC: R-devel <r-devel@stat.math.ethz.ch> > Subject: Re: [Rd] read.table and strip.white > > Prof Brian Ripley wrote: > > [...] > > >Looks like a general problem with a backslashes in "winhelp" (?). > > > > Which system of help, and if text help which pager? (I'm not > > on Windows here to check, but the text file looks fine on Unix. My > > guess is that this a pager bug.) > > The Windows Help system (R-1.0.1, NT4.0): > help(read.table, winhelp=TRUE) > > Text and HTML Help are OK.Thanks, will take a look. winhelp comes with a health warning, and we were thinking of withdrawing now most people have Compiled HTML. Looks like at least one person uses it! It is done by automatic translation from HTML written by someone else, and there are a lot of known problems with it. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> Date: Wed, 31 May 2000 09:11:38 +0200 > From: Uwe Ligges <ligges@statistik.uni-dortmund.de> > X-Accept-Language: en > To: R-devel <r-devel@stat.math.ethz.ch> > CC: busse@statistik.uni-dortmund.de, Joerg Guettner <guettner@gmx.de> > Subject: [Rd] read.table and strip.white > > Hi! > > I want to read data (using read.table(.)) from a file like: > > "col1", "col2", "col3" > 1, 1, 1 > 2, 2, 2 > > > But the white spaces are interpreted: > > x <- read.table("filename", header=TRUE, sep=",") ## or read.csv(...) > colnames(x) > [1] "col1" " col2" " col3" > ^ ^ > > So I would like to pass an argument like strip.white=TRUE (as in > scan(.)) to read.table(.) . > If this is nonsense, please let me know. > > > At my first look only three lines (and documentation) must be changed: > > l. 1-3 add: function(..., strip.white=FALSE, ...) > ^^^^^^^^^^^^^^^^^ > l. 16 + 35 add: ... <- scan(..., strip.white=strip.white, ...) > ^^^^^^^^^^^^^^^^^^^^^^^ >I was rather surprised here, and this is not what the prototype does: .col1. .col2. .col3. 1 1 1 1 2 2 2 2 Should not strip.white be true for the header line? That's what the prototype does: toucan% cat fff col1, col2, col3 a, 1, 1 b, 2, 2 Splus> x <- read.table("fff", header=TRUE, sep=",", row.names=NULL) > xcol1 col2 col3 1 a 1 1 2 b 2 2> as.matrix(x)col1 col2 col3 1 " a" "1" "1" 2 " b" "2" "2" You can always quote on the header line if you really want names with leading spaces. I think we could add strip.white for use in the body, quite easily. Any comments? -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel 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-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._