I want to create a sequence between two letters let's say "b"
and "f"
. So the output is
"b" "c" "d" "e" "f"
For numbers, we can do
2:6 #which gives output as
[1] 2 3 4 5 6
Is there an easy way to do this with letters as well?
I have gone through Generate a sequence of characters from 'A'-'Z' but this produces all the letters and not sequence between specific letters.
My current solution is,
indx <- which(letters %in% c("b", "f"));
letters[indx[1] : indx[2]]
#[1] "b" "c" "d" "e" "f"
This works but I am curious if there is an easy way to do this or a function in any of the package that I have missed?
Note: I do not want letters[2:6]
as I do not know 2 and 6 beforehand. It could be between any two letters.