In the R manual there is one example of seq
as follows:
seq(stats::rnorm(20))
Can someone explain to me what it is doing and is supposed to generate?
You are effectively using this argument along.with
in the seq
function. This argument will tell seq to simply make a vector of the length of the object, which is 20 in your case.
From ?seq
:
generates the sequence 1, 2, ..., length(from) (as if argument along.with had been specified), unless the argument is numeric of length 1 when it is interpreted as 1:from (even for seq(0) for compatibility with S). Using either seq_along or seq_len is much preferred
The help also says
seq(stats::rnorm(20)) # effectively 'along'
So you are using the argument along.with
, which reads:
along.with take the length from the length of this argument.
That's why it generates a sequence with 20 integers, as it's length(rnorm(20L))