[Rd] Silently loading and Depends: versus NAMESPACE imports

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri Feb 24 18:49:11 CET 2012



On 24.02.2012 18:48, Suraj Gupta wrote:
> Correct, nothing happens in terms of startup messages.  No messages are
> shown.
>
> library( my package ) # Performance Analytics message shown
> search()  # PerformanceAnalytics is not in the search list since its in my
> Imports, not Depends
> suppressPackageStartupMessages**( library("PerformanceAnalytics"**)) # no
> message are shown
> search() # PerformanceAnalytics is now in the seach list beneath R_Global
> as expected


OK, and can you please elaborate what is your problem finally?

Uwe Ligges



>
> 2012/2/24 Uwe Ligges<ligges at statistik.tu-dortmund.de>
>
>>
>>
>> On 24.02.2012 18:02, Suraj Gupta wrote:
>>
>>> Sorry, let me provide the details:
>>> My package has a .onAttach function (not a .onLoad).  The .onAttach
>>> constructs a startup message and delivers it via packageStartupMessage().
>>>   I've pasted the code below.  My package has a number of other packages
>>> in Depends and Imports.  Some of the packages in Imports have startup
>>> message (not R message, but package specific messages).
>>>
>>> For example I have PerformanceAnalytics in Imports and it shows:
>>> "Econometric tools for performance and risk analysis.
>>> ..."
>>>
>>
>>
>> And nothing happenms once you start it via
>>
>>   suppressPackageStartupMessages**( library("PerformanceAnalytics"**))
>>
>> right?
>>
>> Uwe Ligges
>>
>>
>>> googoleVis shows:
>>> "Please read the Google Visualisation&   Maps API Terms of Use
>>>
>>> before you use the package:
>>> ..."
>>>
>>> my .onAttach is pretty simple:
>>> .onAttach<- function(...)
>>> {
>>>      mylib = dirname( system.file( package = "spear" ) )
>>>      ver   = packageDescription( "spear" , lib = mylib )$Version
>>>      builddate = packageDescription( "spear" , lib = mylib )$Date
>>>      startupMessage = ""
>>>      startupMessage = paste( startupMessage , "\n\n\n" , sep = "" )
>>>      startupMessage = paste( startupMessage ,
>>> "-----------------------------**------------------------------**
>>> ------------------------------**---------------------------\n"
>>> , sep = "" )
>>>      startupMessage = paste( startupMessage , "SPEAR\n" , sep = "" )
>>>      startupMessage = paste( startupMessage , paste( "(Version " , ver , ",
>>> built: " , builddate , ")\n\n" , sep = "" ) , sep = "" )
>>>      startupMessage = paste( startupMessage , "MY MESSAGE HERE...left out
>>> for brevity" , sep = "" )
>>>      packageStartupMessage( startupMessage )
>>> }
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Fri, Feb 24, 2012 at 8:33 AM, Dirk Eddelbuettel<edd at debian.org>
>>>   wrote:
>>>
>>>
>>>> On 24 February 2012 at 00:27, Suraj Gupta wrote:
>>>> | I don't think that is it.  My startup message is currently in .onAttach
>>>> and I
>>>> | still see startup message from packages that I have moved from Imports
>>>> to
>>>> | Depends.
>>>> | Dirk?
>>>>
>>>> There are / were are few issues intertwined in my case, and yours may
>>>> differ:
>>>>
>>>>   - are the messages from your code / packages and you startup messages ?
>>>>
>>>>   - are they from imported packages ?
>>>>
>>>>   - are they from R (reported 'foo being shadowed' or 'generic bar
>>>> defined')
>>>>
>>>> In my case a combination of using .onAttach and .onLoad (instead of just
>>>> .onLoad) together with import directives in a NAMESPACE file solved the
>>>> issue, as had been suggested on this list.
>>>>
>>>> Dirk
>>>>
>>>> --
>>>> "Outside of a dog, a book is a man's best friend. Inside of a dog, it is
>>>> too
>>>> dark to read." -- Groucho Marx
>>>>
>>>>
>>>         [[alternative HTML version deleted]]
>>>
>>>
>>> ______________________________**________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/**listinfo/r-devel<https://stat.ethz.ch/mailman/listinfo/r-devel>
>>>
>>
>



More information about the R-devel mailing list