Example:
test_fn1 <- function(b,passed=pass){
b*passed}
test_fn2 <- function(a){
pass=10;
print(test_fn1(a))}
test_fn2(2)
It can't find 'pass' so Error:
Error in test_fn1(a) : object 'pass' not found
Is there any way I can pass the local variable created in test_fn2() to test_fn1() as default?
I want to do it by default so that I can use it simply with a vector and lapply(). Example:
test_fn1 <- function(b,passed_vector = pass){
***work with b and passed_vector***}
test_fn2 <- function(a_vector){
pass=***a list of values***;
lapply(a_vector,test_fn1);
}
vector = seq(1:100:10)
test_fn2(vector)