[R] Surprise when indexing with a factor.
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Sat May 8 16:31:39 CEST 2004
pallier <pallier at lscp.ehess.fr> writes:
> Given a named vector 'm' and a factor 'f' whose levels match (e.g.
> when 'm' is the result of a 'tapply' command using the factor f as
> INDEX), my intuition is that m[f] means m[as.character(f)]
It's not like we haven't visited this before. As I recall it, the main
argument for the actual behaviour is that otherwise you can *only*
index named vectors with levels a superset of those of the factor.
It makes little sense to have such a restriction, and even less to
have m[f] change if names are added to m.
--
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