Reputation: 165
I have written code in R in RStudio on a Windows10 PC but need to execute the same code on a Virtual Linux Ubuntu 20.04 machine now. I have installed RStudio on the Ubuntu machine and adjusted the paths but it does not appear to work. What am I doing wrong?
The code I want to use is very simple. I have a folder within all my functions are saved as .R files. I source all the files and then add them through the code.
Code on Windows:
Library_path = "Z:/R_Code/MyLibrary/" #set path to folder
source_files <- list.files(Library_path , "*.R$") # locate all .R files
map(paste0(Library_path, source_files), source)
Output Windows:
> source_files
[1] "function1.R"
[2] "function2.R"
[3] "function3.R"
Code on Linux:
Library_path = "/home/username/pathToFolder/R_code/MyLibrary" #set path to folder
source_files <- list.files(Library_path , "*.R$") # locate all .R files
map(paste0(Library_path, source_files), source)
Output Linux:
> source_files
character(0)
Do the file paths need to be specified differently in RStudio if it runs on Ubuntu? The location of the files on the Ubuntu system is on a mounted share drive, could that be a problem?
Thank you very much for your help!
Upvotes: 1
Views: 198
Reputation: 165
Thank you @r2evans for your help.
I found my mistake: The code works on Windows and Ubuntu, the problem was that the file path systems work differently.
On Windows:
path = "/folder/"
On Linux:
path = "./folder/"
If the point is added it works.
Upvotes: 1