Permalink
Browse files

Proper fix for namespace issues

  • Loading branch information...
hadley committed Dec 24, 2011
1 parent e807061 commit 7cb04ed759c9a858abf4a4d363f439c19f188c16
Showing with 3 additions and 2 deletions.
  1. +3 −2 R/scales-.r
View
@@ -104,8 +104,9 @@ find_global <- function(name) {
return(get(name, globalenv()))
}
- if (exists(name, "package:ggplot2")) {
- return(get(name, "package:ggplot2"))
+ pkg <- getNamespace("ggplot2")
@kohske

kohske Dec 28, 2011

Collaborator

Just a note, this is incompatible with devtools, since getNames("ggplot2") tries to load officially installed ggplot2.

@hadley

hadley Dec 28, 2011

Owner

Hmmm, I haven't had any problems, but maybe I have a running version of ggplot2 floating around. I guess I could try adding the package:ggplot check back in, but only after checking "package:ggplot2" %in% search()

@kohske

kohske Dec 28, 2011

Collaborator

Maybe the best way is that load_all makes a "hook" on getNamespace -- if a dev package is loaded by load_all or something else, getNamespace returns the namespace for the dev package, not sure if this is possible though.

@hadley

hadley Dec 28, 2011

Owner

I wish I knew how to do that.

+ if (exists(name, pkg)) {
+ return(get(name, pkg))
}
NULL

0 comments on commit 7cb04ed

Please sign in to comment.