I have a vector (or matrix, etc.) with two numbers.
Is there a feature or other short βsingle lineβ trick to make these numbers an inclusive sequence?
For instance:
If I have a vector containing numbers 1 and 15. I want to quickly apply a function (or trick) to create a new vector containing 1:15 (1,2,3,4,5,6 ... 15)
I understand that I can use the seq function to create sequences, but this would require me to write both digits from my vector (or matrix, etc.) as "from" and "to".
- In an example where indexing data.frames, lists, or matrices creates long lines of text, it would be nice not to repeat these lines of text for both of the / arguments.
Example:
dat <- data.frame(a = 1:5, b = 1:5, c = 1:5, d = 1:5, e = 1:5, f = 1:5)
source share