I'm trying to debug some ggplot functions and the source of the bug is in scales. So I use devtools but upon load_all() or install() of my locally modified version of scales I get:
Warning message:
‘scales’ namespace cannot be unloaded:
namespace ‘scales’ is imported by ‘ggplot2’ so cannot be unloaded
even after I try
detach("package:ggplot2")
How to proceed here, other than quit/restart R?
PS: on a related note, why is unload not exporter from devtools, it would be useful because my first intuition after reading the error message was: unload("ggplot2")
Jean-Olivier Irisson
---
Observatoire Océanologique
Station Zoologique, B.P. 28, Chemin du Lazaret
06230 Villefranche-sur-Mer
Tel: +33 04 93 76 38 04
Mob: +33 06 21 05 19 90
http://jo.irisson.com/
A probably related issue:
in a new R session I can do
library("devtools")
load_all("/Users/jiho/Software/R/scales/")
library("ggplot2")
and this loads my modified version of scales. Now, if I modify scales and, in the same R session, I do again
load_all("/Users/jiho/Software/R/scales/")
I get a confirmation message
Loading scales
but the changes are not actually taken into account. And if I try
install("/Users/jiho/Software/R/scales/")
I get:
Installing scales
* checking for file '/Users/jiho/Software/R/scales/DESCRIPTION' ... OK
[...]
* DONE (scales)
Reloading installed scales
Warning message:
‘scales’ namespace cannot be unloaded:
namespace ‘scales’ is imported by ‘ggplot2’ so cannot be unloaded
I also tried sourcing just the modified file but these are functions not exported by scales (namely pal_name in scale-brewer.r) so
pal_name
shows the changes, but
scales:::pal_name
does not, and it is the latter that ggplot2 uses.
So basically I need to quit and restart R every time. Kind of annoying ;)
Thanks in advance for any help,
Well, that's the best way ;)
> PS: on a related note, why is unload not exporter from devtools, it would be useful because my first intuition after reading the error message was: unload("ggplot2")
Because, as you've noticed, it's not very reliable. The warning
message comes from R, not devtools.
I can't remember this being a problem for me - so maybe the key is not
use to use library(ggplot2), but use load_all(ggplot2)
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
OK, thanks for the tip. So I'll use load_all("ggplot2"), load_all("scales") in those situations.