Today I have came across some strange problem. I have a data frame of 25 columns (let's say that this column is called Bitcoin). I have a loop and inside that loop I would like to read values from another columns:
for(i in 1:5)
{
a <- a + (Bitcoin[1,5] - Bitcoin[1, 5 + i])
}
Assume that i=4. I should get the value of Bitcoin[1,9] which is 11400, but I always get the number of this column -> 9. When I write two formulas:
Bitcoin[1,9]
Bitcoin[1,5+i]
Values are different, the first is 11400 and the second is 9. Why this is happening?