[R] A bug in the function "scan"?

宮本 友介 yusuke at koko15.hus.osaka-u.ac.jp
Mon Dec 25 16:37:08 CET 2000


Hi,

On Mon, 25 Dec 2000 20:06:45 +0900,
"Dilip N. Thadani" <thadani at tkk.att.ne.jp> wrote:

> Here is what I have in a text file called tmp.txt
> 
> ab,5,b'c,cd,5
> 
> i.e. the file has only one line of data (to keep things simple)
> 
> I issue the command
>  scan(file="c:/tmp.txt",what="",sep=",")
> Read 3 items
> [1] "ab"      "5"       "bc,cd,5"
> 
> >
> 
> Why is it not reading 5 items?  If i remove the apostrophe in the third item
> (ie. b'c => bc) then scan reads all 5 items as I would expect it.
> 
> Is this a bug, or am I missing something about how apostrophe's are treated?


The characters preceded by apostrophe (i.e. 'c,cd,5) is treated 
as `semi-'quoted(unclosed) string. 

You can get the expected result when you quote the strings 
like this:
  "ab",5,"b'c","cd",5

Yusuke
---
MIYAMOTO Yusuke
Graduate School of Human Sciences,
Osaka University, JAPAN
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list