[R] checkUsage from codetools shows errors when function uses functions from loaded packages
Duncan Murdoch
murdoch.duncan at gmail.com
Mon Apr 8 21:03:49 CEST 2013
On 13-04-08 2:29 PM, Jannis wrote:
> Thanks for your reply, Duncan. I hoped for an auutomatic way without
> manually having to load the packages to exist ... Perhaps this time this
> is not the case.
That doesn't make sense. How could checkUsage possibly know what
packages you plan to attach if you don't tell it?
Duncan Murdoch
>
> Cheers
> Jannis
>
> On 08.04.2013 20:25, Duncan Murdoch wrote:
>> On 08/04/2013 2:12 PM, Jannis wrote:
>>> Dear list members,
>>>
>>>
>>> I frequently program small scripts and wrap them into functions to be
>>> able to check them with checkUsage. In case these functions (loaded via
>>> source or copy pasted to the R console) use functions from other
>>> packages, I get this error:
>>>
>>>
>>> no visible global function definition for ‘xxxxxxx’
>>>
>>> For example:
>>>
>>>
>>>
>>> test = function() {
>>> require(plotrix)
>>> color.legend()
>>> }
>>>
>>> library(codetools)
>>> checkUsage(test)
>>>
>>>
>>> Can I tell codetools somehow where to look for these functions without
>>> building a full blown package?
>>
>> Sure, just attach the other package. For example:
>>
>> > f <- function() plot3d(1,1,1)
>> > library(codetools)
>> > checkUsage(f)
>> <anonymous>: no visible global function definition for ‘plot3d’
>> > library(rgl)
>> > checkUsage(f)
>> >
>>
>> Duncan Murdoch
More information about the R-help
mailing list