Girija Kalyani
2014-Aug-28 05:41 UTC
[R] R ERROR- Error in file(file, "rt") : cannot open the connection
Dear R Group, I have an species occurence file stored in dismo/ex/abc.csv. When i read the file, it shows error. Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'G:/Software/R-3.1.1/library/dismo/ex/occurence.csv': No such file or directory What could b the reason, it shows no such file in directory, but i saved my file in the place where i have mentioned in d code. Can someone help me out with this? Thanx in advanvce [[alternative HTML version deleted]]
Sarah Goslee
2014-Aug-28 12:44 UTC
[R] R ERROR- Error in file(file, "rt") : cannot open the connection
Hi, You don't show us your code, and you really should, but most likely you did not put the file where you thought you did, or there's a typo in the name. Using file.choose() may help. Also, I think it's bad practice to put user files in the R library directory. You should make a working directory in your own workspace. Sarah On Thu, Aug 28, 2014 at 1:41 AM, Girija Kalyani <smileismystyl at gmail.com> wrote:> Dear R Group, > > I have an species occurence file stored in dismo/ex/abc.csv. > When i read the file, it shows error. > Error in file(file, "rt") : cannot open the connection > In addition: Warning message: > In file(file, "rt") : cannot open file > 'G:/Software/R-3.1.1/library/dismo/ex/occurence.csv': No such file or > directory > What could b the reason, it shows no such file in directory, but i saved my > file in the place where i have mentioned in d code. > Can someone help me out with this? > Thanx in advanvce >-- Sarah Gosle http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org
Jeff Newmiller
2014-Aug-28 13:36 UTC
[R] R ERROR- Error in file(file, "rt") : cannot open the connection
Such problems usually come from not understanding where files really are, though sometimes odd file permissions can be the culprit. Understanding how backslashes work in R strings also sometimes causes problems, though you seem to be using forward slashes so that may not apply here. You may find that reading the help files could provide more accurate picture about the file system from R's point of view than you currently have in your mind. ?list.files list.files() ?getwd getwd() list.files("G:/Software/R-3.1.1/library/dismo/ex") You should not have to use setwd() to successfully read a file, but it can be convenient. If you confirm the directory is there but you only see a subset of files that you expect, then you may have a permissions problem. My advice is to stay away from changing permissions if at all possible... it usually only occurs because you were doing something "As Administrator" when you shouldn't have been, and fixing that is a pit of despair and off topic here. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On August 27, 2014 10:41:23 PM PDT, Girija Kalyani <smileismystyl at gmail.com> wrote:>Dear R Group, > >I have an species occurence file stored in dismo/ex/abc.csv. >When i read the file, it shows error. >Error in file(file, "rt") : cannot open the connection >In addition: Warning message: >In file(file, "rt") : cannot open file >'G:/Software/R-3.1.1/library/dismo/ex/occurence.csv': No such file or >directory >What could b the reason, it shows no such file in directory, but i >saved my >file in the place where i have mentioned in d code. >Can someone help me out with this? >Thanx in advanvce > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.