0

Im trying to run multiple R files from a master file (as in other statistical softweres like Stata or Python) and, evendough Im already running R studio as an administrator, I keep running into this warning:

Error in file(filename, "r", encoding = encoding) : 
  cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file 'C:/Users/Dani Johansson/Desktop/DATA N RESEARCH/ENDISEG_2/Pre_Eliminary/CODE/R_Code/Data_Cleaning_n_Manipulation': Permission denied

This is the code Ive been using:

#For the sake of organization, the code is divided in the following sub sections:
      #1.) Generalizations
      #2.) Data set coordination



#1.) Generalizations:


data_manipulation_path <- "C:\\Users\\Dani Johansson\\Desktop\\DATA N RESEARCH\\ENDISEG_2\\Pre_Eliminary\\CODE\\R_Code\\Data_Cleaning_n_Manipulation"


#1.)Data set coordination and manipulation
master_data_manipulation <- paste(data_manipulation_path, "\\Master_Data_Manipulation.R")
source(data_manipulation_path)

PD: This was the actual value for data_manipulation_path:

data_manipulation_path <- "C:\Users\Dani Johansson\Desktop\DATA N RESEARCH\ENDISEG_2\Pre_Eliminary\CODE\R_Code\Data_Cleaning_n_Manipulation"

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
  • 1
    Welcome to SO! You can and (should!) edit your question to include any additional information, please do not use the answer section for this. Also note that by default `paste()` adds a space (`" "`) between terms. You can use `paste( sep = "")`, `paste0()` to avoid that. Or better yet, `file.path(data_manipulation_path, "Master_Data_Manipulation.R")` . And you still have `source(data_manipulation_path)` instead of `source(data_manipulation)` – margusl Jan 28 '23 at 23:11
  • Likely a TYPO: even though you define `master_data_manipulation`, you are trying to source its directory. Instead use `source(master_data_manipulation)`. – r2evans Jan 30 '23 at 02:16
  • (Said differently: attempting to call `source` on a directory will fail, and on windows it fails with "permission denied" (other OSes fail in different ways).) – r2evans Jan 30 '23 at 02:20

0 Answers0