[Rd] dimnames usage in ts (PR#1288)
Peter Dalgaard BSA
p.dalgaard@biostat.ku.dk
29 Jan 2002 21:57:51 +0100
tkeitt@ms.cc.sunysb.edu writes:
> I think this code in 'ts' is incorrect:
>
> if (is.matrix(data) || is.data.frame(data)) {
> nseries <- ncol(data)
> ndata <- nrow(data)
> dimnames(data) <- list(NULL, names)
> }
...
> Or else, "dimnames<-.data.frame" has a bug.
It doesn't (well, this isn't one...). A data frame must have unique
rownames, so trying to set them to NULL is wrong, as you say.
The fix would seem to be something like replacing the last line with
if (is.null(dimnames(data)))
dimnames(data) <- list(NULL, names)
else
dimnames(data)[[2]] <- name
Did you actually get bitten by this one?
--
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._