Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imports: dependency no longer sufficient for dependent package plotting #663

Closed
joey711 opened this issue Sep 11, 2012 · 4 comments
Closed

Comments

@joey711
Copy link
Contributor

joey711 commented Sep 11, 2012

The following was my the first stage problem after getting stuck fixing an error from R CMD check mypkg; after updating some of the ways in which custom ggplot2 graphics are produced in mypkg. However, after trying some simple fixes suggested by Hadley and Winston, this superficial bug disappeared to reveal a namespace issue no reflected in the title of this issue tracker post.

"
Why does this appear when trying to plot/render a ggplot object using v0.9.2?

Default print/show/plot for ggplot object now results in a prompt:

Hit <Return> to see next plot:

rather than just rendering the graphic.

That is, show(p) used to be indistinguishable from print(p), and both would automatically produce a graphic on the default graphic device. Now show(p) et al result in the above prompt. Unfortunately, this is stalling some of my ggplot2-dependent function examples. I have not seen this in previous versions.
"

Note that the print(p) problem could be fixed with library(ggplot2), and that this was one of the indications of the namespace change in v0.9.2 of ggplot2.

@hadley
Copy link
Member

hadley commented Sep 11, 2012

Restart with a clean session?

@wch
Copy link
Member

wch commented Sep 11, 2012

I think this happens when you run par(ask=TRUE), but I don't think this should have anything to do with ggplot2.

@joey711
Copy link
Contributor Author

joey711 commented Sep 11, 2012

After restarting with fresh sessions, trying different IDEs, trying an explicit par(ask=FALSE), I managed to get a more useful error:

Error in as.environment(where) : 
  no item called "package:ggplot2" on the search list

This error occurs when using a standard call to one of the custom ggplot2-based plot functions in my package, phyloseq, which has been using ggplot2 as an Imports: dependency. I'm not sure what changed with the namespace of ggplot2, but until now users of phyloseq were able to get graphics to print/show/render without first calling library(ggplot2). Somehow the requisite functions/methods for building the graphics are no longer in the search list. For confirmation, I changed ggplot2 to a Depends: dependency in phyloseq, and that appears to solve the problem, with custom graphics functions working fine.

On some level, I'm okay with making phyloseq users fully load ggplot2, because it gets them that much closer to adding their own customizations to their graphics and using other features of ggplot2. On the other hand, it means adding a lot more "space junk" that wasn't at as much risk of colliding with the Imports: dependency.

So while I think I've found a fix that might even be good for my particular case, I'm wondering

  • (1) Is this the best fix?
  • (2) Are you aware of the namespace change, and consequence for dependent packages? And also, is it intentional (and therefore has some extra benefit/purpose)?

Thanks for not immediately closing the issue. I should have narrowed the problem better before the original question post.

@hadley
Copy link
Member

hadley commented Sep 11, 2012

That's a bug and we just pushed a fix to cran.

@hadley hadley closed this as completed Sep 11, 2012
@lock lock bot locked as resolved and limited conversation to collaborators Jun 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants