Bug 15167 - setHook("plot.new", ) fails with single function
Summary: setHook("plot.new", ) fails with single function
Alias: None
Product: R
Classification: Unclassified
Component: Misc (show other bugs)
Version: R 2.15.2
Hardware: All All
: P5 minor
Assignee: R-core
Depends on:
Reported: 2013-01-12 06:15 UTC by Robert Hijmans
Modified: 2013-01-13 14:27 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Robert Hijmans 2013-01-12 06:15:58 UTC
I believe this fails because R cannot iterate over a single function

> setHook("plot.new", function(...) {}, 'replace')
> plot(1:10)
Error in for (fun in getHook("plot.new")) { : invalid for() loop sequence

# This works because it creates a list of two functions
> setHook("plot.new", function(...) {}, 'replace')
> setHook("plot.new", function(...) {})
> plot(1:10)

> sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: i386-w64-mingw32/i386 (32-bit)

[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
Comment 1 Duncan Murdoch 2013-01-13 14:27:18 UTC
This is a bug in setHook, which I'll fix in R-devel (to become R 3.0.0).  Some packages have been making use of this behaviour so I won't change R-patched, to give them time to adjust their code.