[R] seq argument along.with
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:
>just messing around today and am now perplexed by the seq argument
>Please, I am just just seeking some knowledge here. Obviously I missed
>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
>take the length from the length of this argument (assuming "length"
>refers to length of output). Would that not mean I should get two
>Regardless of the value of the along.with argument, it just returns 1.
>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
>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
>manner, but then I am probably missing some point, subtle or otherwise.
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help