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

baptiste auguie baptiste.auguie at googlemail.com
Mon Nov 22 21:10:20 CET 2010


Apparently He who starts from 0 needn't be called unfortunate,

fortune('indexed')

baptiste

On 22 November 2010 20:59, Ben Bolker <bbolker at gmail.com> wrote:
> 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 ...)
>
> ______________________________________________
> 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