[Rd] Bug? (PR#690)

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
11 Oct 2000 11:45:12 +0200


td2mafea@uco.es writes:

> I donīt know if it is a bug, but what's wrong in the folloing (R version
> 1.1.1, August 15, 2000, under windows 98):
> > x<-matrix(nrow=10, ncol=2)
> > for (i in 1:10)
> + {
> + x[i][1]<-i
> + x[i][2]<-i^2
> + }
> Warning messages:
> 1: number of items to replace is not a multiple of replacement length
> 2: number of items to replace is not a multiple of replacement length

Not a bug. You mean x[i,1] etc. Notice that single-indexing a matrix
ignores dimensions:

> x<-matrix(1:20,nrow=10, ncol=2)
> x[1]
[1] 1
> x[12]
[1] 12


-- 
   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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._