Element in a numeric vector does not change after running a for loop that iterates each element.
I have a numeric vector:
>str(df$Grad.Rate)
num [1:777] 60 56 54 59 15 55 63 73 80 52 ...
I want to update any element>100
> for (i in df$Grad.Rate){
+ if (i >100){
+ print(i)
+ i = 100
+ print(paste0('changed to ', i))
+ }
+ }
[1] 118
[1] "changed to 100"
After I run the for loop, the element that is >100 is still in the vector
> any(df$Grad.Rate>100)
[1] TRUE
Why?