Reputation: 452
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
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 byfile.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 usefile.access
.)
Upvotes: 1