I have an overall function in R with several functions inside, but some of the parameters are not recognized.
The code is summarized here:
  MY_FUNCTION <- function(PATH, n_c = 4, My_Parameter = 100){
  
  library(MY_MODEL)
  
  nc <- n_c
  My_Limit <- 10
  
  # args = a number of arguments are put in the function
  OUTPUT <- genI(args, My_Limit, My_Parameter) # A function within the model
  
  ....
  
  Results <- RUN_MY_MODEL(args, nc = nc) 
  }
When I try to run MY_FUNCTION I get the error:
Error in (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  : 
object 'My_Parameter' was not found
The function can run if I before I run MY_FUNCTION set My_Parameter = 100 and My_Limit = 10 in the console.
What is the difference between: n_c, My_Parameter and My_Limit?
Why is My_Parameter not recognized even when a default value is put in the function?
Best regards, Jesper
EDIT: Normally, I run this part of the code as a script, and that causes no issues
  library(MY_MODEL)
  
  nc <- n_c
  My_Limit <- 10
  My_Parameter <- 100
  
  # args = a number of arguments are put in the function
  OUTPUT <- genI(args, My_Limit, My_Parameter) # A function within the model
  
  ....
  
  Results <- RUN_MY_MODEL(args, nc = nc)
In this way there are no problems with My_Parameter and My_Limit in any of the sub-functions.
My code is running a very large model (I did not make that myself) and making this reproducible is not possible. :-(
