0

what's wrong with my code I can not open the file in r studio

location = "C:/R/Practice/practice1"

filename = paste(location,"SDG20200430.CSV",sep="/")

HAPPY <- read.table(filename, header=TRUE, sep=",")


> HAPPY <- read.table(filename, header=TRUE, sep=",")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") :
  cannot open file 'C:/R/Practice/practice1/SDG20200430.CSV': No such file or directory
Phil
  • 7,287
  • 3
  • 36
  • 66
  • Is your C:/ protected from being accessed by other applications? – Mohanasundaram Apr 30 '20 at 15:22
  • 1
    (1) You "should" use `file.path` instead of `paste` when constructing paths. What you have does not appear to be the problem, though. (2) Does `list.files(location)` include your CSV file name? – r2evans Apr 30 '20 at 15:23
  • location = "C:/Users/82109/Desktop/same/SDG20200430.CSV" filename = file.path(location,"SDG20200430.CSV",sep="/") Mydata <- read.table(filename, header=TRUE, sep=",") – nannaya Apr 30 '20 at 15:44
  • Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'C:/Users/82109/Desktop/same/SDG20200430.CSV/SDG20200430.CSV/': No such file or directory – nannaya Apr 30 '20 at 15:46
  • I still can not find what's wrong with it.....is there any possibility that the actual file is wrong? – nannaya Apr 30 '20 at 15:47
  • If you have, try loading from a different drive E:/ or F:/ and see. Also, try using \\ instead of /. – Mohanasundaram Apr 30 '20 at 16:03
  • Try with read.csv as well – Mohanasundaram Apr 30 '20 at 16:05

0 Answers0