[R] File Reading Problem
jimingyu at princeton.edu
Tue Sep 2 01:54:54 CEST 2003
Thank you very much. I think it's working by using:
mytry<-readBin("Source.txt", n=2325120, size=1, what="int")
where n is the maximum size of the text file. So there may be no big
I'd really appreciate your help. Thanks.
----- Original Message -----
From: "Prof Brian Ripley" <ripley at stats.ox.ac.uk>
To: "Jiming Yu" <jimingyu at Princeton.EDU>
Cc: <r-help at stat.math.ethz.ch>; "Martin Maechler"
<maechler at stat.math.ethz.ch>
Sent: Monday, September 01, 2003 11:47 AM
Subject: Re: [R] File Reading Problem
> ?readBin will do what you want. If the file is really a set of lines,
> you could use readLines() followed by strsplit().
> See also the R Data Import/Export manual.
> On Mon, 1 Sep 2003, Jiming Yu wrote:
> > Dear all,
> > I am trying to read characters byte by byte(in their ASCII codes)
> > file(already transferred from text file to a file of ASCII codes, by C
> > language). I am using scan() function. But it seems that this is
> > If I read data as 'character' type, data are read word by word,
> > separated by spaces(though in default setting, sep=""). e.g. if a file
> > contains "This is a book.", Then it reads "This", "is", "a", "book.",
> > "T", "h", "i", "s", etc(as I wanted it to).
> > If I read data as 'integer' type from the file which contains all
> > codes of the original file, e.g. if a file contains "This is a book.",
> > it reads "T", " ", "i", " ", "a", " " , "b", which are initials of all
> > and all spaces, not "T", "h", "i", "s", etc(as I wanted it to).
> > If anybody has a solution, please let me know. I'd really appreciate
> > your help. Thank you very much!
> 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 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help