I would like to know how I can calculate the amount of elements I have in a predefined range, within a vector.
For example: Let's say I have a vector of size 10. My intention for example is to want to know how many elements have between the second element of my vector up to the sixth element of my vector.
vetor=c(1,2,3,4,5,6,7,8,9,10)
I want to know how many numbers I have between the second element of my vector ( vetor[2]
) and the sixth element ( vetor[6]
). Which in this case are 5 elements.
NOTE: In this case I want the second and the sixth element to be part of the count.