From p.dalgaard@biostat.ku.dk  Thu Feb 11 18:31:55 1999
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 11 Feb 1999 19:31:55 +0100
Subject: An idea for something better than read.table
In-Reply-To: Kurt Hornik's message of Thu, 11 Feb 1999 19:10:27 +0100 (CET)
References: <x2g18c3ka9.fsf@blueberry.kubism.ku.dk> <14019.7443.446135.700056@pc87.maho.magnaeu.com>
Message-ID: <x2d83g3i78.fsf@blueberry.kubism.ku.dk>

Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> writes:

> > [There's another loose idea in there involving a control item to handle
> > separators, na.strings, etc. - the intention being that read() plugs
> > in the file= and skip= arguments for the actual call.]
> 
> > Would this be an approach worth pursuing?
> 
> I think so.  However, why can't we extend scan() accordingly?
> 
> E.g.,
> 
>   scan(FILE,
>        what = list(Item = factor(levels=1:4,labels=c("A","B","C","D")),
>                    Size = numeric(),
>                    Year = factor(levels=1980:1985)))
> 
> ???

We could, and in a sense that is what I'm suggesting, but:

- the argument syntax is a bit clumsy, I'd like to have the variables
through a ... argument.

- scan *evaluates* the arguments and then looks at the type.
Evaluating things like

factor(levels=1:4,labels=c("A","B","C","D")) 

currently gives a "missing x" error, but even if we fixed that, it
could never give anything better than

> structure(integer(0),class="factor",levels=c("A","B","C","D"))
factor(0)
Levels:  A B C D 

i.e. the levels= specification would be forgotten. The only way to
circumvent that is to have scan working on nonevaluated arguments.

So I thought that one might as well start over with a completely new
function. 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


An idea for something better than read.table
Peter Dalgaard BSA