That definitely looks like a bug, but not one that anyone will be eager
to fix. It's very old code that tried to be clever, and that's the
hardest kind of code to fix.
Remember Kernighan's Law: "Everyone knows that debugging is twice as
hard as writing a program in the first place. So if you’re as clever as
you can be when you write it, how will you ever debug it?"
Duncan Murdoch
On 2024-07-05 7:35 a.m., Erez Shomron wrote:
Is the following a bug in your opinion? I think so.
This works as expected:
```
with(mtcars, plot(wt, mpg, plot.first = {
plot.window(range(wt), range(mpg))
arrows(3, 15, 4, 30)
}))
```
This does not.
```
plot(mpg ~ wt, data = mtcars, plot.first = {
plot.window(range(wt), range(mpg))
arrows(3, 15, 4, 30)
})
```
With error:
```
Error in arrows(3, 15, 4, 30) : plot.new has not been called yet
```
The second example should work.
From the docs:
?plot.formula
" For the ‘plot’ method the formula can be of the form ‘~ z + y +
z’: the variables specified on the right-hand side are collected
into a data frame, subsetted if specified, and displayed by
‘plot.data.frame’.
"
?plot.data.frame
" ...: further arguments to ‘stripchart’, ‘plot.default’ or ‘pairs’.
"
And plot.default has both plot.first and plot.last
It seems very arbitrary you can't use these parameters with the plot.formula
method specifically.
sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-suse-linux-gnu
Running under: openSUSE Tumbleweed
[...]
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.