# [R] seq argument along.with

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Sat Apr 15 00:54:49 CEST 2017

```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