Hello there, Much thanks in advance for any help. I have a few questions: 1) Why do I keep getting the following error: File1 <- read.csv("../RawData/File1.csv",as.is=TRUE,row.names=1) Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file '../RawData/File1.csv': No such file or directory ? More specifically, my directories are set up in the following way: SampleProject RawData SampleCode The current script is in the SampleCode folder. File1.csv is in the RawData folder. I'm a bit confused why this error keeps occurring. I googled it and found many other people getting the same error, but was not sure why mine remained incorrect... 2) Ultimately what I want to do is take File1.csv, File2.csv and File3.csv (all in the RawData folder) and basically add them together such that it was as if they were all on one big csv file to begin with. I thought I knew how to do this but I'm using a mac now-- is there something different between the code to do this with R Studio and on a Mac and using Tinn R on Windows? In any case, I would really very much appreciate any help on both these issues. Thank you again. benjamin [[alternative HTML version deleted]]
Hi Fred, It seems you don't have an rbind() problem, but a path problem. The error you're getting means R can't find your file. When specifying a relative path, as you do with "../RawData/File1.csv" it's relative to your current working directory, not necessarily the directory where your script is. You can check that with getwd() and change it with setwd(). The safest thing to do is to specify an absolute path instead, such as "/home/user/whatever/RawData/File1.csv" but if you want to use relative paths, for instance for repeatability, then just check your working directory carefully. Sarah On Fri, Jan 20, 2012 at 3:39 PM, Fred G <bayespokerguy at gmail.com> wrote:> Hello there, > > Much thanks in advance for any help. ?I have a few questions: > > 1) Why do I keep getting the following error: > > File1 <- read.csv("../RawData/File1.csv",as.is=TRUE,row.names=1) > Error in file(file, "rt") : cannot open the connection > In addition: Warning message: > In file(file, "rt") : > ?cannot open file '../RawData/File1.csv': No such file or directory > > ? > > More specifically, my directories are set up in the following way: > ? ? SampleProject > ?RawData ? SampleCode > > The current script is in the SampleCode folder. ?File1.csv is in the > RawData folder. ?I'm a bit confused why this error keeps occurring. ?I > googled it and found many other people getting the same error, but was not > sure why mine remained incorrect... > > 2) Ultimately what I want to do is take File1.csv, File2.csv and File3.csv > (all in the RawData folder) and basically add them together such that it > was as if they were all on one big csv file to begin with. ?I thought I > knew how to do this but I'm using a mac now-- is there something different > between the code to do this with R Studio and on a Mac and using Tinn R on > Windows? > > In any case, I would really very much appreciate any help on both these > issues. > > Thank you again. > > benjamin > > ? ? ? ?[[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.-- Sarah Goslee http://www.stringpage.com http://www.sarahgoslee.com http://www.functionaldiversity.org
As Sarah said, you have a path problem. Are you saying that RawData is a sub-folder (sub-directory) of SampleProject? And you are running the script with the working directory set to SampleProject? [check using getwd() as Sarah suggested] If so, it looks like it would work if you use './RawData/File1.csv'. The ".." causes it back up one directory (folder) above the working directory before looking for RawData. You can also use file.choose() to find the file, and that will tell you what the correct path is. There's nothing special about how R on the Mac finds input files, or how it uses rbind(). It does it in the standard R way. (I have no idea how much different it might be using R Studio or Tinn R on Windows.) -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 1/20/12 12:39 PM, "Fred G" <bayespokerguy at gmail.com> wrote:>Hello there, > >Much thanks in advance for any help. I have a few questions: > >1) Why do I keep getting the following error: > >File1 <- read.csv("../RawData/File1.csv",as.is=TRUE,row.names=1) >Error in file(file, "rt") : cannot open the connection >In addition: Warning message: >In file(file, "rt") : > cannot open file '../RawData/File1.csv': No such file or directory > >? > >More specifically, my directories are set up in the following way: > SampleProject > RawData SampleCode > >The current script is in the SampleCode folder. File1.csv is in the >RawData folder. I'm a bit confused why this error keeps occurring. I >googled it and found many other people getting the same error, but was not >sure why mine remained incorrect... > >2) Ultimately what I want to do is take File1.csv, File2.csv and File3.csv >(all in the RawData folder) and basically add them together such that it >was as if they were all on one big csv file to begin with. I thought I >knew how to do this but I'm using a mac now-- is there something different >between the code to do this with R Studio and on a Mac and using Tinn R on >Windows? > >In any case, I would really very much appreciate any help on both these >issues. > >Thank you again. > >benjamin > > [[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.
Possibly Parallel Threads
- Doubts on incremental backup and command repetition
- [LLVMdev] Compile units in debugging intrinsics / globals
- rsync in conjunction with the --link-dest option does not output deleted files
- Utility function to rotate log files?
- [LLVMdev] Compile units in debugging intrinsics / globals