Jan Janiszewski
Jan Janiszewski

Reputation: 452

R cannot open an existing file

Can somebody explain to me possible reasons and solutions to why R cannot open a connection to an existing file?

> file.exists("config.R")
[1] TRUE
> source('config.R')
Error in file(filename, "r", encoding = encoding) : 
  cannot open the connection

Upvotes: 0

Views: 231

Answers (1)

Joel
Joel

Reputation: 1574

From the R Documentation:

file.exists returns a logical vector indicating whether the files named by its argument exist. (Here ‘exists’ is in the sense of the system's stat call: a file will be reported as existing only if you have the permissions needed by stat. Existence can also be checked by file.access, which might use different permissions and so obtain a different result. Note that the existence of a file does not imply that it is readable: for that use file.access.)

Upvotes: 1

Related Questions