sclaes + ggplot development, how to unload packages?

1,290 views
Skip to first unread message

Jean-Olivier Irisson

unread,
Mar 27, 2012, 5:02:05 AM3/27/12
to ggplot2-dev
Hi all,

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/

Jean-Olivier Irisson

unread,
Mar 27, 2012, 5:10:11 AM3/27/12
to ggplot2-dev
On 2012-Mar-27, at 11:02 , Jean-Olivier Irisson wrote:
> Hi all,
>
> 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


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,

Hadley Wickham

unread,
Mar 27, 2012, 10:05:44 AM3/27/12
to Jean-Olivier Irisson, ggplot2-dev
>
> How to proceed here, other than quit/restart R?

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/

Jean-Olivier Irisson

unread,
Mar 27, 2012, 10:28:43 AM3/27/12
to Hadley Wickham, ggplot2-dev
On 2012-Mar-27, at 16:05 , Hadley Wickham wrote:
>
> 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)

OK, thanks for the tip. So I'll use load_all("ggplot2"), load_all("scales") in those situations.

Reply all
Reply to author
Forward
0 new messages