Re: [Rd] read.csv

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Sun, 14 Jun 2009 16:37:51 -0400

On Sun, Jun 14, 2009 at 4:21 PM, Ted
Harding<Ted.Harding_at_manchester.ac.uk> wrote:
> Or am I missing something?!!

The point of this is that the current behavior is not desirable since you can't have quoted numeric fields if you specify colClasses = "numeric" yet you can if you don't. The concepts are not orthogonal but should be. If you specify or not specify colClasses the numeric fields ought to be treated the same way and if the documentation says otherwise it further means there is a problem with the design.

One could define their own type quotedNumeric as a workaround (see below) but I think it would be better if specifying "numeric" or not specifying
numeric had the same effect. The way it is now the concepts are intertwined and not orthogonal.

library(methods)
setClass("quotedNumeric")
setAs("character", "quotedNumeric",
  function(from) as.numeric(gsub("\"", "", from))) Lines <- 'A,B
"1",1
"2",2'
read.csv(textConnection(Lines), colClasses = c("quotedNumeric", "numeric"))



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sun 14 Jun 2009 - 20:43:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 16 Jun 2009 - 11:36:02 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive