[R] unexpected results

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Wed Jun 19 22:35:56 CEST 2002


On Wed, 19 Jun 2002, Niels Waller wrote:

>
>
> Is R behaving correctly in this example? I do not understand why column 2
> has any 2s in it (and why column 3 has any 1s)

Why do you think it should not have?  Remember the re-cycling rule.
You've filled elements *in row-major-order* alternately as 1 and 2.

> > x<-matrix(0,10,3)
> > x[seq(1,10,by=2),2:3]<-c(1,2)
> > x
>       [,1] [,2] [,3]
>  [1,]    0    1    2
>  [2,]    0    0    0
>  [3,]    0    2    1
>  [4,]    0    0    0
>  [5,]    0    1    2
>  [6,]    0    0    0
>  [7,]    0    2    1
>  [8,]    0    0    0
>  [9,]    0    1    2
> [10,]    0    0    0

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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