An idea for something better than read.table

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
11 Feb 1999 19:31:55 +0100


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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._