[R] problem using ts after tapply

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Thu Jul 27 13:24:28 CEST 2000


Colin Farrow <c.farrow at compserv.gla.ac.uk> writes:

> here is a distillation of a problem encountered in transfering some
> working code from R-0.63 to R-1.1.0
> 
> a1 <- 1:10
> b1 <- tapply(a1,a1, sum)
> c1 <- ts(b1)
> c1
> Error in if (NCOL(x) == 1) { : missing value where logical needed
> 
> note that the error is returned as the value of calling ts() and is not
> automatically displayed
> 
> problem seems to be that 
> is.array(b1) returns TRUE
> yet dim(b1) returns 10
> 
> bug or feature or am I missing something?

It's a feature in tapply that it generates a 1-D array, but one might
consider it a bug in print.ts, ts, or NCOL that the dim() is carried
through and the 1-D case not handled. You can easily work around
it by setting dim(c1)<-NULL or dim(b1)<-NULL.

-- 
   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
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list