[R] Using read.table to read file created with read.table and qmethod = "escape"

Peter Ehlers ehlers at ucalgary.ca
Thu Apr 8 09:36:56 CEST 2010


This worked for me in R 2.11.0 alpha:

df <- data.frame(a = "a\"b", v = 4, z = "this is Z")
write.csv(df, "test.csv", row.names = FALSE, quote = FALSE)
read.csv("test.csv", quote = "")

  -Peter Ehlers

On 2010-04-07 19:09, Hadley Wickham wrote:
> df<- data.frame(a = "a\"b")
> write.table(df, "test.csv", sep = ",", row = F)
>
> Is there any to load test.csv into R correctly?  I've tried the following:
>
>> read.table("test.csv", sep = ",")
> [1] V1
> <0 rows>  (or 0-length row.names)
> Warning message:
> In read.table("test.csv", sep = ",") :
>    incomplete final line found by readTableHeader on 'test.csv'
>> read.table("test.csv", sep = ",", allowEscapes = T)
> [1] V1
> <0 rows>  (or 0-length row.names)
> Warning message:
> In read.table("test.csv", sep = ",", allowEscapes = T) :
>    incomplete final line found by readTableHeader on 'test.csv'
>
> And I can't see any other options in read.table that would apply.
>
> Regards,
>
> Hadley
>
>

-- 
Peter Ehlers
University of Calgary



More information about the R-help mailing list