How to Open CSV File in R When R Says "No Such File or Directory"

How to open CSV file in R when R says no such file or directory?

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

Why R Markdown does not import .csv files and says there is no such file at the directory

You might have better luck using the absolute path (or full path) instead of the relative path to the file.

On MacOS, select the file, press Command + I to open up the information pane, and copy the text portion of Where, which should give you the absolute path to the folder the file is in. Copy that to R, and add your file name. There are other ways to do it as well.

The major advantage of using the absolute path is that you don't have to worry about your current working directory when importing data.

my computer can't find my csv file in r

There are three ways you can read file.

For example, you have to downloaded in Desktop (example for mac) then

First: provide full path

mydata <- read.csv("/Users/test/Desktop/bit121GBP.csv", header =TRUE)

Second: Provide relative path

mydata <- read.csv("~/Desktop/bit121GBP.csv", header =TRUE)

Third: Set path

setwd("~/Desktop")
mydata <- read.csv("bit121GBP.csv", header =TRUE)

R: Cannot Open File : No such file or directory

Change the line:

b.files <- paste0("Files_", a.files) 

to:

b.files <- paste("Files_", a.files, sep="")

You are using a version of R that does not have paste0 (I see that code was given to you in an earlier answer). This means you were keeping an earlier version of b.files, perhaps one that had been constructed using paste.

One important lesson about this is that whenever you get an error message about a line, such as Error: could not find function "paste0", that means the line did not happen! You have to fix that error before you paste the code, or tell us about the error when you do- otherwise we assume the b.files <- paste0("Files_", a.files) line works.



Related Topics



Leave a reply



Submit