It is a promising solution. Yet, there is room for improvement. I revise the if condition so it won't throw an error during ordinary startup.
.First <- function() { if (length(commandArgs(T))>0 && commandArgs(T)[1] == "ld"){ load(commandArgs(T)[-1], .GlobalEnv) } } For the Rload script, it should be: gnome-terminal --command "R --args ld '$1'" Note the single quotation of $1. Without it, it does not work if the file name contains space. HTH Best Ronggui On 12 January 2009 23:45, Zhou Fang <zhou.zf...@gmail.com> wrote: > Well, that isn't ideal for my purposes. (A little context - basically > I have a script that I'm running for a lot of simulations, which is > kinda buggy, and what I'm doing is I'm having the script periodically > save whatever it has done so far to an automatically named file. Then > if something odd happens in between two saves, I can run forward from > a previously saved point to find the problem and figure out why it > happened, and also I won't risk losing everything if something > catastrophic happens.) > > Anyways, if anyone's interested, in .Rprofile > > .First <- function(){ > if (rev(commandArgs())[2] == "ld"){ > load(rev(commandArgs())[1], .GlobalEnv) > } > } > > Then e.g. > > alias Rload='R --arg ld' > > or make a bash script with > > gnome-terminal --command "R --args ld $1" > > and set some Open With options, and you'll be about to open R > workspaces from Nautilus etc by point and click. > > Zhou > > > On Mon, Jan 12, 2009 at 3:14 PM, Gabor Grothendieck > <ggrothendi...@gmail.com> wrote: >> Another possibility is to have a separate directory >> for each project and place an .RData file in each. >> Now just cd to whatever directory corresponds to the >> project you wish to work on and start R normally. >> No code is needed. >> >> On Mon, Jan 12, 2009 at 10:04 AM, Zhou Fang <zhou.zf...@gmail.com> wrote: >>> Ok, looks like I can do what I want with --args, commandArgs() and an >>> appropiate .First. >>> >>> Thanks, >>> >>> Zhou >>> >>> On Mon, Jan 12, 2009 at 2:27 PM, David Winsemius <dwinsem...@comcast.net> >>> wrote: >>>> See if this material is helpful: >>>> >>>> http://cran.r-project.org/doc/manuals/R-intro.html#Invoking-R-from-the-command-line >>>> >>>> -- David Winsemius >>>> >>>> On Jan 12, 2009, at 7:24 AM, Zhou Fang wrote: >>>> >>>>> That's not really what I meant by 'command line'. I meant, well, >>>>> loading from e.g. a bash shell, not from within an interactive R >>>>> session itself. >>>>> >>>>> Thanks anyways, >>>>> >>>>> Zhou >>>>> >>>>> (Possibly this email was sent twice. Apologies) >>>>> >>>>> On Mon, Jan 12, 2009 at 12:15 PM, Henrique Dallazuanna <www...@gmail.com> >>>>> wrote: >>>>>> >>>>>> See ?load >>>>>> >>>>>> On Mon, Jan 12, 2009 at 10:12 AM, Zhou Fang <zhou.zf...@gmail.com> wrote: >>>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> Is there any way to load workspaces (e.g. stuff from save.image) from >>>>>>> the command line? I'm on Linux, and would find this very helpful. >>>>>>> >>>>>>> I'm guessing this functionality can be duplicated with a skillful bash >>>>>>> script to rename the particular file to .RData (and then back once R >>>>>>> terminates), but I'm wondering if there's a better way. >>>>>>> >>>>>>> Zhou Fang >>>>>>> >>>>>>> ______________________________________________ >>>>>>> R-help@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. >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Henrique Dallazuanna >>>>>> Curitiba-Paraná-Brasil >>>>>> 25° 25' 40" S 49° 16' 22" O >>>>>> >>>>> >>>>> ______________________________________________ >>>>> R-help@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. >>>> >>>> >>> >>> ______________________________________________ >>> R-help@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. >>> >> > > ______________________________________________ > R-help@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. > -- Wincent Ronggui HUANG Doctoral Candidate Dept of Public and Social Administration City University of Hong Kong http://asrr.r-forge.r-project.org/rghuang.html ______________________________________________ R-help@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.