# [R] seq argument along.with

Carl Sutton suttoncarl at ymail.com
Sat Apr 15 01:58:48 CEST 2017

```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 <jdnewmil at dcn.davis.ca.us> wrote:

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 is of zero length, is to show that vector to the seq function as an example of how long to make the result.
--
Sent from my phone. Please excuse my brevity.

On April 14, 2017 2:55:48 PM PDT, Carl Sutton via R-help <r-help at r-project.org> wrote:
>
>
>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.with = 2)  What is the purpose of this argument????
>
>per "help" page
> along.with
>take the length from the length of this argument (assuming "length"
>here
>refers to length of output).  Would that not mean I should get two
>
>numbers?
>
>
>Regardless of the value of the along.with argument, it just returns 1.
>Which
>
>then leads me to be believe that the output will be the number (length)
>of arguments,i.e., length of the along.with argument, which indeed it
>does.
>
>seq(1,10,along.with = c(1,3,5,7))  yields 1 4 7 10
>
>seq(1,10,along.with = c(111,13,5555,7) yields 1 4 7 10
>
>seq(1,10,along.with = c("a","b","c","d")) yields 1 4 7 10
>
>
>Obviously the authors of this function saw a need for this argument,
>but I am
>just not bright enough to figure out what that purpose was.  It appears
>
>to me that length.out does the same thing in a much more
>straightforward
>manner, but then I am probably missing some point, subtle or otherwise.
>
>Carl Sutton
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help