[R] Cannot read or write to file in Linux Ubuntu

John Kane jrkrideau at inbox.com
Thu May 3 20:50:46 CEST 2012


Thanks Jeff and Sarah.  

I was thinking mainly of using the base path and paste routine which is something I do in Windows  

It will take me a while to figrue out relative paths.  

John Kane
Kingston ON Canada


> -----Original Message-----
> From: sarah.goslee at gmail.com
> Sent: Thu, 3 May 2012 14:07:12 -0400
> To: jdnewmil at dcn.davis.ca.us
> Subject: Re: [R] Cannot read or write to file in Linux Ubuntu
> 
> On Thu, May 3, 2012 at 1:53 PM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
> wrote:
>> "I like the idea of staying with absolute paths."
>> 
>> Before you write too much R code that builds in absolute paths, please
>> consider how difficult it will be to adjust all of those paths if you
>> need to run on a different computer or you need to reorganize your
>> overall directory structure. If you keep related R files in the same
>> project directory, you can collapse all of those paths down to short
>> relative paths, and do one setwd at the beginning, or learn to manually
>> set your base working directory as a matter of habit before each working
>> session. (This habit is useful in more areas than just R programming.)
> 
> I agree with this, which is why I suggested you use absolute paths
> *until you get more comfortable with the file system.* It's a good way
> to diagnose your problem and figure out how to deal with paths on
> Linux, but not a good long-term strategy unless you expect that you
> will never ever move anything or change to a new computer.
> 
> An intermediate solution that I use a lot is to put something like
> this at the beginning of R script file:
> basepath = "/home/sarahg/whatever"
> and then load files using something like
> read.table(paste(basepath, "plantdata.csv", sep="/"))
> 
> This eases portability between computers: I exchange a lot of analyses
> with postdocs, students and techs, and somehow they've not all become
> convinced that my way of organizing directories is the best one. Using
> an object with the absolute path for the data means that we can pass
> things back and forth with only changing one value within the script
> rather than all input/output commands.
> 
> Sarah
> 
> --
> Sarah Goslee
> http://www.functionaldiversity.org
>

____________________________________________________________
TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if5
Capture screenshots, upload images, edit and send them to your friends
through IMs, post on Twitter®, Facebook®, MySpace™, LinkedIn® – FAST!



More information about the R-help mailing list