Problem to open files

#1
Hello everyone! I am a starter user, and I have a problem to open a file.

First of all, I set the folder
> setwd("C:\\users\\stefano\\documents\\r-documenti")

After, I check that it has worked.
> getwd()
[1] "C:/users/stefano/documents/r-documenti"

Finally I tried to open my csv file:
> reddit <- read.csv("reddit")
Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'reddit': No such file or directory

This is the path of the file called "reddit"
C:\Users\stefano\Documents\R-documenti

However I can open it from the menu, but I'd like to understand what is wrong in my commands
 

hlsmith

Not a robit
#2
I think you fell into the biggest initial trip up using R, rerun code but turn all of the back slashes into forward slashes.

\ should be /
 

Dason

Ambassador to the humans
#3
I think you fell into the biggest initial trip up using R, rerun code but turn all of the back slashes into forward slashes.

\ should be /
No their code looks fine. They double escaped the backslashes.

Can you run dir() after the call to setwd and she us the output. Also keep in mind R is case sensitive.
 
#4
It works now. Thank you. Using the command dir() I've seen that R see the name of this file as "reddit.csv", instead just reddit. Another thing.. I saw that if I close R studio and after that I open again the main folder return following this path "C:/Users/stefano/Documents", instead this ("C:\\users\\stefano\\documents\\r-documenti").
 

Dason

Ambassador to the humans
#5
Documents will be your default R home. You'll need to use setwd in all of your scripts. If you want a different default you could consider making/modifying your .Rprofile file to make a call to setwd when you load R.