• Register
0 votes
432 views

Problem :

I am very new to the R, and after researching my error as below extensively, I am still unable to find the fix for it. I have already checked my working directory, and also made sure that the files are in a correct directory.

Error in file(file, "rt") : cannot open the connection file(file, "rt") read.table(file = file, header = header, sep = sep, quote = quote,dec = dec, fill = fill, comment.char = comment.char, ...)
read.csv(specdatapaths[i], header = T, sep = ",")pollutantmean3("specdata", "sulfate", 1:10)
In addition: Warning message:
In file(file, "rt") : cannot open file './specdata001.csv': No such file or directory

 

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I had spent a lot of time in recent past trying to understand what was actually wrong with my code.

And it seems to be very simple if you are using windows.

When you name the file "xyz.txt" then your windows name it as "xyz.txt.txt"... That will be the same with .CSV files as well so windows create the file named "007.csv.csv" if you called it "007.csv"

So, whenever you try to create your .csv file, you just rename it as"007" and open it in the R using below command :

read.table("/absolute/path/of/directory/with/required/007.csv")

 It will work for you as it works for me.

9 7 4
38,600 points

Related questions

0 votes
1 answer 5 views
5 views
Problem: I'm new to R, and after researching this error extensively, I'm still not able to find a solution for it. Here's the code. I've checked my working directory and made sure the files are in the right directory. The error I'm getting is below: Error in file(file, “rt”) : cannot open the connection Thanks
asked Mar 30 ummesalma 24.5k points
1 vote
2 answers 1.1K views
1.1K views
Problem : I am getting following error while trying to read the CSV file with R. in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : eof within quoted string
asked Nov 11, 2019 peterlaw 6.9k points
0 votes
1 answer 36 views
36 views
Problem: I have this error, any help: Error in file(filename, "r", encoding = encoding) : cannot open the connection
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
2 answers 1.8K views
1.8K views
Problem : I have the RScript file (let's call it main.r) which has the reference to another file, using the following code: source("functions.R") But, when i run a RScript file, it complains with the following error: Error in file(filename, "r", encoding = encoding) ... next to the functions.R in a same directory. I can call a functions.R in a RMd (RMarkdown) file which exist in a same directory
asked Jan 17, 2020 jwilliam 3.9k points
0 votes
1 answer 5 views
5 views
Problem: I'm trying to create a plot from elements of CSV file. I am receiving an error saying Error in data.frame(id = varieties, attr(mat, "row.names"), check.rows = FALSE) : arguments imply differing number of rows: 8, 20
asked Mar 30 ummesalma 24.5k points
0 votes
1 answer 33 views
33 views
Problem error in readchar(con, 5l, usebytes = true) : cannot open the connection
asked Feb 9 charles mathews 5.5k points
0 votes
1 answer 2 views
2 views
problem: please help to solve fatal error c1083: cannot open include file: 'config-win.h': no such file or directory.
asked 1 day ago ashik 11.2k points
0 votes
1 answer 19 views
19 views
Problem : I am facing following error : Importerror: libcuda.so.1: cannot open shared object file: no such file or directory .
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 29 views
29 views
Problem: How can I fix this issue: Importerror: libgl.so.1: cannot open shared object file: no such file or directory
asked Mar 14 Wafa Abu Yousef 6.1k points
0 votes
1 answer 15 views
15 views
Problem; HELP! I need help understanding this error and why it still happened to me : Fatal error c1083: cannot open include file: 'mysql.h': no such file or directory.
asked Mar 6 Wafa Abu Yousef 6.1k points