I have a xlsx file and to read from Rstudio i saved it as .csv file. Now when i try to read the file from Rstudio, receiving the below error.
setwd("D:/DATA SCIENCE/CCPP-Linear regression")
ccpp<- read.csv("Folds5x2_pp.csv", header = TRUE)
Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'Folds5x2_pp.csv': No such file or directory
As already mentioned in the comments, the "cannot open the connection" part of the error message confirms that where R is looking is not where the file is.
A few things to keep in mind
getwd()
to see the current R working directorysetwd()
to change R's wd"DATA\ SCIENCE"
.read.csv("D:/DATA SCIENCE/path/file.csv")
) or if you are doing this a lot, set a variable to your pathdata_path ="D:/DATA SCIENCE/path/"
and thenread.csv(file.path(data_path, "file.csv"))
wherefile.path
concatenates with your OS specific path delimiter.