[R] Is it possible to make a matrix to start at row 0?

Ben Bolker bbolker at gmail.com
Mon Nov 22 20:59:23 CET 2010


Bert Gunter <gunter.berton <at> gene.com> writes:

> 
> Eh??? Why would you want to do that?? (R isn't C).
> 
> So the simple answer is: you can't.
> 
> The other answer is, well of course you sort of can via, e.g.
> 
> for(i in 0:9)  {
>    z <- myMatrix[i+1,]
>   ...
> }
> 
> But as Josh said, I think this falls into the class of "You are just
> asking for trouble, so don't do it."
> 
> Cheers,
> Bert

  But if you still want to after all those warnings, you can ...
see the "Oarray" package, where the first letter of the package
name is a capital letter "oh" (O), not a zero (0).

 library("fortunes"); fortune("Yoda")

 There ought also to be a clever fortune() expressing the sentiment
that you may eventually find (weeks, months, or years later) that
changing the way you solve your problem to go with R's flow would
have been easier than implementing a solution that works around
the flow (examples abound: <<-, zero-based arrays, eval(parse()), 
storing names  of variables as character vectors and using get()
[FAQ 7.21], etc, etc, etc ...)



More information about the R-help mailing list