Hi, I am using the scan function to read from a file. In general the syntax I am using is as follows: scan("myfile", list(a = "", b="", c="", d=""), sep=",") The file I am trying to read contains a #< in the 'd' field. When the file is read into an object, the d field comes as "" for that particular string. I guess the problem is because the # is used for commenting. My question is that if I want to read the #< anyways from the file, how do I do that? Thanks in advance. -Saket. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 14 May 2002 joshi at engr.orst.edu wrote:> Hi, > > I am using the scan function to read from a file. In > general the syntax I am using is as follows: > > scan("myfile", list(a = "", b="", c="", d=""), sep=",") > > The file I am trying to read contains a #< in the 'd' > field. When the file is read into an object, the d > field comes as "" for that particular string. > > I guess the problem is because the # is used for > commenting. > My question is that if I want to read the #< anyways > from the file, how do I do that?Options: 1) Read the help page for scan, and set the appropriate argument to make # not a comment character, or (preferably) 2) Upgrade to the current version of R, where it will work with the default values. *Please* do remember to tell us your R version/platform when posting. -- Brian D. Ripley, ripley at 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-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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello, it looks you using R1.4.X in this case you have to add comment.char = "" to your scan command, because '#' is used to mark comments. In R1.5.0 "" is the default (that means: no comments allowed), which is the better option beacause there are many different comment chars in tht different file types. gruess joerg joshi at engr.orst.edu wrote:> > Hi, > > I am using the scan function to read from a file. In > general the syntax I am using is as follows: > > scan("myfile", list(a = "", b="", c="", d=""), sep=",") > > The file I am trying to read contains a #< in the 'd' > field. When the file is read into an object, the d > field comes as "" for that particular string. > > I guess the problem is because the # is used for > commenting. > My question is that if I want to read the #< anyways > from the file, how do I do that? > > Thanks in advance. > -Saket. > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- Joerg Maeder .:|:||:..:.||.:: maeder at atmos.umnw.ethz.ch Tel: +41 1 633 36 25 .:|:||:..:.||.:: http://www.iac.ethz.ch/staff/maeder PhD student at INSTITUTE FOR ATMOSPHERIC AND CLIMATE SCIENCE (IACETH) ETH Z?RICH Switzerland -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 14 May 2002 joshi at engr.orst.edu wrote:>Hi, > >I am using the scan function to read from a file. In >general the syntax I am using is as follows: > >scan("myfile", list(a = "", b="", c="", d=""), sep=",")try using comment.char = "", as in scan("myfile", list(a = "", b="", c="", d=""), sep=",", comment.char = "") so that # isn't seen as a comment eg if its inside a string "abc#def" the string gets read properly Regards Peter> >The file I am trying to read contains a #< in the 'd' >field. When the file is read into an object, the d >field comes as "" for that particular string. > >I guess the problem is because the # is used for >commenting. >My question is that if I want to read the #< anyways >from the file, how do I do that? > >Thanks in advance. >-Saket. >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- >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 >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-- Dr Peter Baker, Statistician (Bioinformatics/Genetics), CSIRO Mathematical & Information Sciences, 120 Meiers Rd, INDOOROOPILLY, QLD 4068. Australia. Email: <Peter.Baker at csiro.au> WWW: http://www.cmis.csiro.au/Peter.Baker/ Phone:+61 7 3214 2210 Fax:+61 7 3214 2881 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._