Full_Name: Paul Murrell
Version: 2.1.0 (unsure how long it has been there)
OS: Linux
Submission from: (NULL) (130.216.50.118)
Submitted by: paul
There seems to be a problem with escaped quotes in read.table.
Suppose this is the contents of a text file called "temp.txt" ...
6 'TV2 Shortland Street'
2 'I don\'t watch TV at 7'
1 'I\'m not bothered, whatever that looks good'
2 'I channel surf'
> x <- read.table("temp.txt")
> x
V1 V2
1 2 I channel surf
2 6 TV2 Shortland Street
3 2 I don't watch TV at 7
4 1 I'm not bothered, whatever that looks good
5 2 I channel surf
(what is "I channel surf" doing as the first row?!)
Problem goes away if I use \" instead of \' or if I leave it as \'
and change
the outer quotes from single to double. e.g. ...
2 "I don\'t watch TV at 7"
Analysis from Brian Ripley:
The problem is that readTableHead does not handle embedded quotes and so thinks
there are three lines on that file. See the comment in scan.c
/* <FIXME> This does not handle escaped quotes, nor does it appear to
use the blank.lines.skip arg */