0

I am having some sudden issues with Rstudio in an iMac. I always save my data as txt file to import to Rstudio. But recently, my Mac has had some issues with this. I use the code

xdata=read.table(file="mydata.txt",header=T,sep="\t")

and what I get is:

Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'mydata.txt': No such file or directory

It's not a pathway problem, because I have already set the setwd to the folder where the file is located.

Even though the file is there, the file does not show up in the 'files' section of Rstudio (it was showing up yesterday, now it's not). I tried the exact same thing on a different computer (windows) and it worked fine. The file is displaying in the folder and Rstudio imports the data normally.

Any ideas of what is going on with my Mac? It was working fine until it suddenly stopped working. I have uninstalled and reinstalled Rstudio and I have updated the packages and the mac itself.

Phil
  • 7,287
  • 3
  • 36
  • 66
  • Something to note: just because you set the working directory doesn't mean that the Files pane of RStudio is showing that exact directory. You'll have to use the "More > Go to Working Directory" option in Files. Chances are there was something wrong with your file path or maybe you had the file open. – OTStats Sep 14 '21 at 14:52
  • Does this answer your question? [How to open CSV file in R when R says "no such file or directory"?](https://stackoverflow.com/questions/5568847/how-to-open-csv-file-in-r-when-r-says-no-such-file-or-directory) – OTStats Sep 14 '21 at 14:52

1 Answers1

0

Thanks for your help. I tried the steps in the link, and it didn't work. But I did a test by creating a new project on my desktop, and it worked fine, so I figured out the issue: The cloud! My project did not sync between two devices, so it created a different project, which was overwriting everything on that folder.

So I simply switched to the "new" project, and I could see all my files!

General Grievance
  • 4,555
  • 31
  • 31
  • 45