It seems that I am messing up with file location or names but I am not able to understand the error exactly. I think the gap between G
and _T
is telling something please help me in interpretting.
Error:
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file 'C:\o_a\f_q/M/s_O-G _T.txt': No such file or directory
CodePudding user response:
There are several possible issues:
Your file name has combinations of forward (
/M/
) and backward (\o
) slashes, which indicates you are not specifying the correct file path. Try setting them to all be the same type of slash.You might not be specifying an actual file/folder! Copy the
C:\o_a\f_q/M/s_O-G _T.txt
into your file explorer (e.g. the bar at the top of Windows Explorer if you are a Windows user) and try to go to it. Is there anything there? Trying moving up one level by usingC:\o_a\f_q/M
instead (i.e. removing everything after the last slash and the slash itself).You might be specifying an absolute path when a relative path is expected. Think about R as starting within some folder/directory on your computer when it looks for files. It will then typically search for a specified file by looking within that directory for it using the name you profile. However, that file might be in another folder not within that folder itself - i.e. another level up or a level over in the directory structure. File paths can depend on where R assumes you are starting. Here's some useful discussion.
Without more knowledge of your settings, system, and files it is hard to provide more precise identification of the issue.
However, you can circumvent needing to know some of this for now by entering file.choose()
into the R console. You'll be able to navigate to the file you need manually. The big downside of this is that you'll have to do this every single time you want to use that file without some additional work.