[R-SIG-Mac] .First() function not being executed on R.app startup

Simon Urbanek simon.urbanek at r-project.org
Wed Nov 28 03:30:10 CET 2007


On Nov 27, 2007, at 9:25 PM, Steven McKinney wrote:

> Hi Simon,
>
> Thanks for checking.  I'm not sure
> then why mine is not working.
>
> I removed all objects, and set up your
> example .First function:
>
>
>> rm(list = ls(all = TRUE))
>> ls(all = TRUE)
>   character(0)
>> .First <- function() cat(".First was called\n")
>> ls(all = TRUE)
>   [1] ".First"
>> .First
>   function() cat(".First was called\n")
>> q()
>
> I saved the workspace after q(), then started
> R.app again (from the R.app icon in the dock).
> The message does not appear, though the .First
> function is still there:
>
>   R version 2.6.1 (2007-11-26)
>   Copyright (C) 2007 The R Foundation for Statistical Computing
>   ISBN 3-900051-07-0
>
>   R is free software and comes with ABSOLUTELY NO WARRANTY.
>   You are welcome to redistribute it under certain conditions.
>   Type 'license()' or 'licence()' for distribution details.
>
>     Natural language support but running in an English locale
>
>   R is a collaborative project with many contributors.
>   Type 'contributors()' for more information and
>   'citation()' on how to cite R or R packages in publications.
>
>   Type 'demo()' for some demos, 'help()' for on-line help, or
>   'help.start()' for an HTML browser interface to help.
>   Type 'q()' to quit R.
>
>   [Workspace restored from /Users/stevenmckinney/.RData]
>
>> ls(all = TRUE)
>   [1] ".First"
>> .First
>   function() cat(".First was called\n")
>>
>
>
> I notice that your session does not show a message such as
> "[Workspace restored from /Users/stevenmckinney/.RData]"
>
> Something is different about our setup.
>
> Any idea why I get this message and you do not?
> Is your .First just saved in
> ~/.RData ?
>

No, mine is in ~/.Rprofile
AFAIR .RData is treated differently in the R GUI, because it is  
loaded *after* R has been initialized. This comes from the way R is  
started in the GUI, so I don't think you can use .First in the saved  
workspace.

Cheers,
Simon


> Best
> Steve M
>
>
> -----Original Message-----
> From: Simon Urbanek [mailto:simon.urbanek at r-project.org]
> Sent: Tue 11/27/2007 5:45 PM
> To: Steven McKinney
> Cc: R-SIG-Mac at stat.math.ethz.ch
> Subject: Re: [R-SIG-Mac] .First() function not being executed on  
> R.app startup
>
> Steven,
>
> can you be more specific, please? I cannot reproduce your
> problem, .First works for me just fine:
>
> R version 2.6.1 (2007-11-26)
> Copyright (C) 2007 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
>
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
>
>    Natural language support but running in an English locale
>
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
>
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
>
> .First was called
>> .First
> function() cat(".First was called\n")
>
> Cheers,
> Simon
>
>
> On Nov 27, 2007, at 6:00 PM, Steven McKinney wrote:
>
>> Hi all,
>>
>> I've set up a .First function to run help.start()
>> but when I invoke R.app the .First function is not
>> apparently executed.  I've checked preferences and
>> documentation but can not find any indication that
>> .First() should not be executed.
>>
>> Is this a bug in R.app, or have I missed something
>> about how to get .First() to be invoked when
>> I run R.app?  I include session information below.
>> When I invoke R from a terminal shell, help.start()
>> is executed and a browser window does pop up, but
>> not when I invoke R from R.app.
>>
>> Any information appreciated.
>>
>> Best
>>
>> Steve McKinney
>>
>>
>> R version 2.6.1 (2007-11-26)
>> Copyright (C) 2007 The R Foundation for Statistical Computing
>> ISBN 3-900051-07-0
>>
>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>> You are welcome to redistribute it under certain conditions.
>> Type 'license()' or 'licence()' for distribution details.
>>
>>   Natural language support but running in an English locale
>>
>> R is a collaborative project with many contributors.
>> Type 'contributors()' for more information and
>> 'citation()' on how to cite R or R packages in publications.
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>> 'help.start()' for an HTML browser interface to help.
>> Type 'q()' to quit R.
>>
>> [Workspace restored from /Users/stevenmckinney/.RData]
>>
>>> ls(all=TRUE)
>> [1] ".First"    ".required"
>>> .First
>> function(){utils::help.start()}
>>> sessionInfo()
>> R version 2.6.1 (2007-11-26)
>> powerpc-apple-darwin8.10.1
>>
>> locale:
>> en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>>
>>
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>>
>>
>
>
>



More information about the R-SIG-Mac mailing list