Suppose I have four doubles a, b, c, d that at various points in my script will assume different real numbers. Assume also that all four doubles have values that center around another double called X. Namely, the following relationships must always hold:
a = X + 1b = X + 5c = X + 10d = X + 15
In my script, the value of X is always changing. How do I write a function such that a, b, c, d change alongside X?
Creating the setAll function below and calling whenever X changes will of course not work but is in the spirit of what I want.:
setAll <- function(X) {
a = X + 1
b = X + 5
c = X + 10
d = X + 15
}
setAll(100) #if X = 100
environmentfor such variables instead of hacking in the.GlobalEnv? Or your could also follow some OO guidelines especially with reference classes: adv-r.had.co.nz/R5.html