[R] Is it possible to make a matrix to start at row 0?
Mike Marchywka
marchywka at hotmail.com
Mon Nov 22 21:48:15 CET 2010
----------------------------------------
> To: r-help at stat.math.ethz.ch
> From: bbolker at gmail.com
> Date: Mon, 22 Nov 2010 19:59:23 +0000
> Subject: Re: [R] Is it possible to make a matrix to start at row 0?
>
> Bert Gunter gene.com> writes:
>
> >
> > Eh??? Why would you want to do that?? (R isn't C).
> >
> > So the simple answer is: you can't.
Eh, it is open source for a reason. I wouldrecommend however
if you let your zero-base version out in the wild you rename
it to R0 or something. Seriosuly 1-based arrays annoy me
but I'm not sure what happens if you modify R LOL.
> >
> > 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 ...)
>
> ______________________________________________
> 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