Re: [R] Is there a better way than x[1:length(x)-1] ?

2006-08-10 Thread Gabor Csardi
Jack, in R : is an ordinary function with two arguments, ie. 1:10 is a function call with arguments 1 and 10. This way at the time : is evaluated the variable which will be indexed is not known; it is thus impossible to know its length. This is why it is not easy to implement end in R. Since R

Re: [R] Is there a better way than x[1:length(x)-1] ?

2006-08-10 Thread Petr Pikal
Hi On 9 Aug 2006 at 17:30, John McHenry wrote: Date sent: Wed, 9 Aug 2006 17:30:47 -0700 (PDT) From: John McHenry [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Is there a better way than x[1:length(x)-1] ? Hi

Re: [R] Is there a better way than x[1:length(x)-1] ?

2006-08-10 Thread Gabor Grothendieck
On 8/9/06, John McHenry [EMAIL PROTECTED] wrote: Hi WizaRds, In MATLAB you can do x=1:10 and then specify x(2:end) to get 2 3 4 5 6 7 8 9 10 In R you could do the above via: x[-1] or whatever (note that in MATLAB the parenthetic index notation is used, not brackets as in R).

[R] Is there a better way than x[1:length(x)-1] ?

2006-08-09 Thread John McHenry
Hi WizaRds, In MATLAB you can do x=1:10 and then specify x(2:end) to get 2 3 4 5 6 7 8 9 10 or whatever (note that in MATLAB the parenthetic index notation is used, not brackets as in R). The point is that 'end' allows you to refer to the final index point of the array. Obviously there