Subsetting R with dynamic variables [duplicate]
问题 This question already has answers here : Brackets make a vector different. How exactly is vector expression evaluated? (3 answers) Closed 3 years ago . I have the below example code. I have a dataframe ts which has 16 rows. when I subset with actual numbers it works fine but when I subset with calculated numbers why is my code behaving weirdly ? Can anyone please explain me what's wrong in this? Case1: > a [1] 12 > c [1] 16 > ts$trend[13:16] [1] 21.36926 21.48654 21.60383 21.72111 > ts$trend