How to open CSV file in R when R says "no such file or directory"?
Try
f <- file.choose()
to choose the file interactively and save the name in f
.
Then run read.csv
on the saved filename
d <- read.csv(f)
I had to combine Maiasaura and Svun answers to get it to work: using setwd and escaping all the slashes and spaces.
setwd('C:\\Users\\firstname\ lastname\\Desktop\\folder1\\folder2\\folder3')
data = read.csv("file.csv")
data
This solved the issue for me.
Sound like you just have an issue with the path. Include the full path, if you use backslashes they need to be escaped: "C:\\folder\\folder\\Desktop\\file.csv"
or "C:/folder/folder/Desktop/file.csv"
.
myfile = read.csv("C:/folder/folder/Desktop/file.csv") # or read.table()
It may also be wise to avoid spaces and symbols in your file names, though I'm fairly certain spaces are OK.
To throw out another option, why not set the working directory (preferably via a script) to the desktop using setwd('C:\John\Desktop')
and then read the files just using file names