Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
923 views
in Technique[技术] by (71.8m points)

csv - Can't find file in R directory after new session is open

I have been working on an R project with RStudio for a while and when I went back to edit a few lines today I couldn't connect to the csv file I had in my directory and that I had been working with all this time.

When I try to rerun the code it tells me that the file doesn't exist/is not in the directory (but it's there, I can see it in my finder folder).

Just when I write my first two lines of code this is the error message I'm getting:

library(ggplot2)
read.csv("Airbnb_Milan.csv")

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

I've tried to change the file's location and even open another script and download the csv file again but nothing has worked so far. Any clue what to do here?

question from:https://stackoverflow.com/questions/65840143/cant-find-file-in-r-directory-after-new-session-is-open

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

try getwd() to really see the contents of your current working directory. You can set the correct path to the file via setwd(). If you make sure that the path that you look in finder is the same that you set as working directory, you will be fine.

Best


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...