[R] Concatenation, was Re: Physical Units in Calculations
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Mon Apr 13 11:15:33 CEST 2009
Stavros Macrakis wrote:
> It would of course be nice if the existing difftime class could be fit
> into this, as it is currently pretty much a second-class citizen. For
> example, c of two time differences is currently a numeric vector,
> losing its units (hours, days, etc.) completely.
That's actually a generic feature/issue of c(). We also have
> c(factor(1),factor(3))
[1] 1 1
> library(survival)
Loading required package: splines
> c(Surv(1,T),Surv(2,F))
[1] 1 1 2 0
and similar issues apply to rbind() of data frames,
> rbind(data.frame(s=Surv(1,T)),data.frame(s=Surv(2,F)))
s.time s.status
1 1 1
2 2 0
There is some potential for redesigning this, using a concat() generic
which should do the Right Thing for all classed vector-like objects.
(There is such a function in Splus, but I don't their data frame code is
using it.)
--
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