Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206235

Function with different sources in R

$
0
0

here is a sample code :

While I run the code without the function by entering for example :

x <- 5 

The code runs perfectly without any errors.

Moreover when I try to call x with a function, it seems that the different sources do not take in account the x entered while computing the function,

Does someone encounter a similar issue ?

Thank you in advance

f1 <- function(x){

    try(source("~/source1.R"), silent = TRUE) 

    if(nresults==0){
      source("~/source2.R") 

    source("~/source3.R")

    print(results)
}

The value of x (5) is expected to be used in the 3 source files.


Viewing all articles
Browse latest Browse all 206235

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>