Despite the similar title, this is not the same question as Vectorizing rep and seq in R.
My immediate goal: Given a vector, I want to generate a new vector containi
In R, one of the easiest way to vectorize a function is to use the Vectorize
function.
Basically, you can vectorize the from
an to
argument and give all the starter as a vector in the from
argument and do the same thing for the to
argument.
Using your example, you can do something like this
seq2 <- Vectorize(seq.default, vectorize.args = c("from", "to"))
unlist(seq2(from = c(1, 1.75), to = c(2, 2.75), by = 0.25))
## [1] 1.00 1.25 1.50 1.75 2.00 1.75 2.00 2.25 2.50 2.75