[Rd] read.table versus read.csv (PR#9284)

Ben Bolker bolker at zoo.ufl.edu
Tue Oct 10 15:45:43 CEST 2006


 
Arnost.Komarek <at> med.kuleuven.be> writes:
> 
> Dear R Core Team,
> 
> Help to 'read.table' claims that
> 'read.csv' is identical to 'read.table' except for the defaults.

  Pedantically speaking, the claim is true: the difference is
in the default for the quote= argument.

> 
> However, 'read.table' seems to have problems when reading character =20
> variables containing single quotes (') whereas 'read.csv' does not. 

  This behavior is documented, if perhaps not obvious.

from ?read.table:

read.table(file, header = FALSE, sep = "", quote = "\"'",
 [snip]
     read.csv(file, header = TRUE, sep = ",", quote="\"", dec=".",
              fill = TRUE, comment.char="", ...)

Both single and double quotes are included in the default quote=
argument for read.table(), only double quotes are included
in the default for read.csv().

  To make read.csv() behave like read.table() in this respect, specify

read.csv(...,quote="\"'")

  a brief search in svn logs, RSiteSearch, etc., doesn't shed any
light on *why* this difference is there ...

  Ben Bolker




More information about the R-devel mailing list