Is there any way I can define a function in R with a constant determined from a variable? I'm not sure how to say that better so here is an example.
> index<-3
> f<-function(x){x+index}
> f(4)
[1] 7 #Great!
> index<-20
> f(4)
[1] 24 #No! I still want to see 7!
Thank you!