I have these two R scripts which will be sourced in same R instance.
Script 1:
fun1 <- function(x, y)
{
ret = x+y+mean(x,y)
return(ret)
}
fun2 <- function(x, y, z)
{
k = fun1(x, y)
print(x+y+k)
}
I want script 2 to be like this
fun3 <- function(k, l)
{
k = fun4(k, l)
m = k / sd(k,l)
return(m)
}
fun4 <- function(k, l)
{
ret = k+l+mean(k,l)
return(ret)
}
But what people write is
fun3 <- function(k, l)
{
k = fun1(k, l)
m = k / sd(k,l)
return(m)
}
But I dont want to allow functions in script 1 to be called from script 2. How can I do this?
I know I can do this in script 1 but there are many functions like fun2 and some of them are huge, so this is not possible for me
fun2 <- function(x, y, z)
{
fun1 <- function(x, y)
{
ret = x+y+mean(x,y)
return(ret)
}
k = fun1(x, y)
print(x+y+k)
}
I know about creating new environments, but I am not sure will that help.