Looking very closely at your screen shot, commenters are suggesting that you have an extra space at the beginning of your file name.
Also, I see that the working directory appears to be correct (the error message lists it as C:/users/mdavi/Desktop/School/Research/Sc
, which appears to match what is listed in the Files pane
A couple of strategies for trouble-shooting file-locating problems:
- use
getwd()
and list.files()
to confirm your working directory and what files R can see from there (you can read this introduction to get more background on working directories):
- use
file.choose()
to select a file interactively; it's generally a bad idea to use this in production code, as it will add an interactive step when you usually want to be able to run all of your code start to finish without needing manual steps, but it's quite useful for debugging.
If you wanted R to list files that approximately matched your specified filename, you could use
L <- list.files(pattern="*.csv")
agrep("myfile.csv", L, value=TRUE)
You need to set your working directly correctly, either via setwd("~/Desktop/School/Research/SC")
in the R Console (that's what I think I see in your screenshot: ~
stands for your home directory, i.e "Users/Whoever") or via Session > Set Working Directory > To File Pane
in the RStudio menus.
You can read a variety of Stack Overflow questions about setting the working directory for more complete context ... web searching on "R 'working directory'" might help too.