[GK001][Payment] How to source functions if you need to move your R function file folder to another directory?

[GK001][Payment] How to source functions if you need to move your R function file folder to another directory?

[GK001][Payment] How to source functions if you need to move your R function file folder to another directory?

$10.00

Category:

Description

I put all of my R functions in C:/r folder. Usually one function will need to call other functions, in this case we will source the function using source(“C:/r/……R”). However, if I copy the whole r folder to another directory, for example, D: drive. I need to manually change all the code to be source(“D:/r/……R”).
For example there are two functions:


print_hello<-function(){
print("Hello")

#here we want to call and run print_world function
source("C:/r/print_world.R")
print_world()
}
print_world<-function(){
print("World")
}

To run this funcion, you can use:

source("C:/r/print_hello.R")
print_hello()

We can see that the first function calls the second function by code: source(“C:/r/print_world.R”).
If we need to move the R function folder r to D: drive, we need to change all to source(“D:/r/print_world.R”).

There is one simple way that you don’t need to change any code wherever you move you r folder to.

[Continue to read full article…]

Reviews

There are no reviews yet.

Be the first to review “[GK001][Payment] How to source functions if you need to move your R function file folder to another directory?”