[R] binding vectors or matrix using their names

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Mar 25 09:39:29 CET 2004


<Bill.Venables at csiro.au> writes:

> A more serious, philosophical word on Patrick's solution. It is
> rarely necessary (in my limited experience, sure) to have to use
> parse() like this. Where it provides a quick (kludgy?) solution I
> often find it a useful exercise to consider alternatives. They often
> come out simpler and you nearly always pick up something useful in
> the process.

Agreed. And the kludges (yes, they are) are prone to unexpected
behaviour if you try to use them generally. R's modelling code has
quite a few (not that I've counted them) constructs of the type

  formula <- parse(paste("~", paste(terms, collapse="+")))

which breaks down horribly if one the terms has a nonstandard name
like `age in years`. Somewhere on my horizon is the task of hunting
down all of these and replace them with something independent of
textual representation.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list