Re: [R] seq argument along.with

2017-04-15 Thread Rui Barradas
Hello, A good example of a use case of seq_along is to avoid constructs such as 1:length(x) that don't make sense and are a source for bugs whenever x is of length zero. See for instance loops where careless coders do for(i in 1:length(x)){ x[i] <- some computation } If x is of lengt

Re: [R] seq argument along.with

2017-04-14 Thread Carl Sutton via R-help
Hi Jeff I have seen the seq_along function but never knew the what or why of it.  Your response is much appreciated and just shows how brilliant the creators of R were/are. Thank you for enlightening me. Carl Sutton On Friday, April 14, 2017 3:54 PM, Jeff Newmiller wrote: Have you eve

Re: [R] seq argument along.with

2017-04-14 Thread Jeff Newmiller
Have you ever used the seq_along() function? If you want to delegate the decision of how many elements you want to process to some earlier point in your (or someone else's) code, then the most logical way to create a result vector that is the same size as some input vector, even if that vector

[R] seq argument along.with

2017-04-14 Thread Carl Sutton via R-help
Hi just messing around today and am now perplexed by the seq argument "along.with". Please, I am just just seeking some knowledge here. Obviously I missed a point and would like to know what it is. seq(1,10,length.out = 2) makes sense seq(1,10,by = 2) makes sense seq(1,10, along.wi