[R] Create a matrix with increment and element with zero subscript

S Ellison S.Ellison at LGCGroup.com
Tue Oct 25 14:45:51 CEST 2011


 R. Michael Weylandt wrote:
> 
> This may be an unnecessary aside, but other than obfuscating 
> code or allowing people to never stop thinking in C and start 
> thinking in R, what practical purpose would this package 
> serve in an R context?
> 

I'd think about constructs like 
income[1990:2010]

which work nicely with arbitrary indexing. (Oarray isn;t just 0)

Fortran has it natively; C doesn't, but it was useful enough for Numerical Recipes to provide code for arbitrary array index origin for C arrays (it used a pointer shift, if I recall correctly). The most obvious native R appraoch I can think of is using names (eg income[paste(1990:2010)] ), which is very general but has its own disadvantages in terms of readability and, maybe, speed. 

 S Ellison
LGC*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list