R inconsistency: why add=T sometimes works and sometimes not in the plot() function?

后端 未结 2 1344
无人共我
无人共我 2020-12-24 00:30

Why is R inconsistent with the add parameter in the plot() function? It sometimes works and sometimes doesn\'t! In this example, it takes the param

2条回答
  •  一整个雨季
    2020-12-24 01:21

    This is admittedly annoying and inconsistent, but it's explicable.

    edit: the fact that identity is a built-in object (identity function) eluded me (so the problem is in fact reproducible).

    identity is an object of a class -- function -- that has a plot method (plot.function) with an add argument, while the default plot method does not have an add argument.

    In general, when trying to plot object bar, you should try class(bar); if it is of class foo then try methods(class="foo") to see that it has a plot method, or methods("plot") to see that plot.foo exists. Try ?plot.foo to see help, or plot.foo or getAnywhere(plot.foo) to see the function itself.

提交回复
热议问题