[R] Condition warning: has length > 1 and only the first element will be used
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Thu Oct 16 00:10:14 CEST 2008
Joe Kaser wrote:
> Thanks for the help. ifelse does the job.
> Could you elaborate, or give an example of the "awkward" things ifelse
> might do to classed objects?
>
It strips the class. One thing that usually gets me is this:
> dd <- as.Date(c("2008-1-2","2007-3-21"))
> ifelse(dd>as.Date("2008-1-1"),dd+7,dd)
[1] 13887 13593
> dd
[1] "2008-01-02" "2007-03-21"
> dd+7
[1] "2008-01-09" "2007-03-28"
(Actually, the result gets the attributes of the _condition_, which is
usually no help at all.)
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list