error no such file or directory

error "no such file or directory" in r
could someone please tell me why I get the error "no such file or directory" in r?

I used getwd() and copied the directory from there, still get the same error

Hi,

Welcome to the RStudio community!

You either have to use the pull path name (e.g. from the root of your computer) or the path relative from the current working directory.

So if you have a windows machine you can for example call a file like this

read.csv("C:/Users/username/Documents/Rfiles/myFile.csv")
#Or if your getwd() says: C:/Users/username/Documents
read.csv("Rfiles/myFile.csv")

The fact that your path starts with '/' suggest you are on a linux or mac right? Try and see what the full path is in the file explorer.

Hope this helps,
PJ

thank you for your response

yes i'm using mac, I checked the full path and copied it to set the working directory
still when I try to read the csv file, I get the error that there is no such file or directory

sorry I don't know what else I could say to describe the problem
It seems like the most simple thing to do but I keep getting the error

Is this happening for all links to data or or just this file? I'm sure you double checked the filename and extension, so I'm curious if it's happening for other files too ...

you can use the command file.choose() and then follow the menu to find the file you want. This function will return the correct path to the file.

Paths become much easier to deal with if you use projects in Rstudio (file -> new project), as then you can use relative paths from the project directory.

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.