[R] Matrix starting at [0,0] instead of [1,1]?

Gabor Grothendieck ggrothendieck at gmail.com
Thu Oct 16 03:47:19 CEST 2008


If you are willing to use character instead of numeric you can:

> xx <- matrix(1:4, 2, 2, dimnames = list(as.character(0:1), as.character(0:1)))
> xx
  0 1
0 1 3
1 2 4
> xx["0", "1"]
[1] 3


On Wed, Oct 15, 2008 at 9:29 PM, Guillaume Filteau <filteau at unc.edu> wrote:
> Hello all,
>
> When I create a matrix, is there a way to make it start at [0,0], instead of
> [1,1]?
>
> That way, a 2x2 matrix would go from [0,0] to [1,1], instead of [1,1] to
> [2,2].
>
> Best,
> Guillaume
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list