Re: [Rd] Debugging namespace problems

From: Martin Morgan <mtmorgan_at_fhcrc.org>
Date: Fri, 23 Dec 2011 14:19:38 -0800

On 12/23/2011 02:11 PM, Martin Morgan wrote:
> On 12/23/2011 11:54 AM, Hadley Wickham wrote:
>> And one last note: I'm reasonably certain I haven't forgotten to
>> export an S3 method because I wrote the following script to (crudely)
>> compare the function definitions in ggplot2 with its namespace:
>>
>> ns<- parseNamespaceFile("ggplot", "~/Documents/ggplot/")
>>
>> s3e<- paste(ns$S3methods[, 1], ns$S3methods[, 2], sep = ".")
>>
>> f<- ls("package:ggplot2")
>> s3<- f[str_detect(f, fixed("."))]
>>
>> missing<- setdiff(s3, s3e)
>> missing[!str_detect(missing, "bolus|icon")]
>>
>> (Code isn't reproducible, but should give you the basic idea)
>
> I think it's this line
>
> if (!exists(scale_name, globalenv()))
> next
>
>
> in scales_add_defaults, where the symbol isn't found in the globalenv()
> when nstest is attached and ggplot2 only loaded, but is (via the search
> path) when ggplot2 is attached.

and topenv(parent.frame()) is a replacement that gets to .GlobalEnv for ggplot2, and to the name space for nstest.

Martin

>
> Martin
>
>
>>
>> Hadley
>>
>>
>> On Fri, Dec 23, 2011 at 1:52 PM, Hadley Wickham<hadley_at_rice.edu> wrote:
>>> I should add that I'm pretty sure this is something wrong with the
>>> ggplot2 NAMESPACE because if I explicitly attach ggplot2 the code
>>> works:
>>>
>>>> library(nstest)
>>>> my_plot()
>>> Error in UseMethod("scale_dimension") :
>>> no applicable method for 'scale_dimension' applied to an object of
>>> class "NULL"
>>>> library(ggplot2)
>>>> my_plot()
>>> # Plot appears.
>>>
>>> Hadley
>>>
>>> On Fri, Dec 23, 2011 at 1:50 PM, Hadley Wickham<hadley_at_rice.edu> wrote:
>>>> Hi all,
>>>>
>>>> I frequently find that I've failed to export something in my NAMESPACE
>>>> and hence my package doesn't work when it's imported into another
>>>> package. Does anyone have suggestion for debugging this type of
>>>> problem? R CMD check passes without any ns related errors on both the
>>>> importee and the importer.
>>>>
>>>> I've attached a reproducible example - if you install the development
>>>> version of ggplot2 (e.g. with devtools::install_github("ggplot2") the
>>>> attached package fails R CMD check with:
>>>>
>>>>> ### ** Examples
>>>>>
>>>>> plot(my_plot())
>>>> Error in structure(list(data = data, layers = list(), scales =
>>>> Scales$new(), :
>>>> attempt to apply non-function
>>>> Calls: plot ... my_plot -> ggplot -> ggplot.data.frame -> structure
>>>> Execution halted
>>>> Error: Command failed (1)
>>>>
>>>> Hadley
>>>>
>>>> --
>>>> Assistant Professor / Dobelman Family Junior Chair
>>>> Department of Statistics / Rice University
>>>> http://had.co.nz/
>>>
>>>
>>>
>>> --
>>> Assistant Professor / Dobelman Family Junior Chair
>>> Department of Statistics / Rice University
>>> http://had.co.nz/
>>
>>
>>
>
>

-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 23 Dec 2011 - 22:21:43 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 23 Dec 2011 - 23:00:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive