I am trying to use a function to update a variable inside a data frame. In order to illustrate it, I've made an easy example of what is going on. I need to update a value and the function I created works well, I mean it makes all the calculations but it does not update it. This is what happens:
a <- 1
plus_points <- function(points) {
a <- a + points
return(a)
}
plus_points(2)
a
The sentence plus_points(2)
yields 3, it's ok this is the outcome I expected, but if I run the object a
the outcome is 1 again, I was expecting a satisfactory 3. Never happened. Thanks for your advice.