[R] rbind()

Sarah Goslee sarah.goslee at gmail.com
Fri Jan 20 23:48:54 CET 2012


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



More information about the R-help mailing list