What would be the best practice when we would like to share variables across multiple sub-functions of same package (no need to update the content of those variables). e.g.
function1 <- function() {
var1 <<- "x"
var2 <<- "y"
sub_function1()
sub_function2()
}
sub_function1 <- function() {
print(var1)
}
sub_function2 <- function() {
print(var2)
}
Is it best practice to define global variables? I am just worried that if this package used in conjunction with other packages then global variables might interfere with each other. Is it best practice to pass as parameters?