[R] unexpected plot behavior
Martin Renner
greatauklet at gmail.com
Sun Apr 22 08:25:00 CEST 2012
Thank you for the replies, Uwe and Marc. These are explanations that make perfect sense. However, shouldn't the behavior of plot.factor include the option of type = "n" for consistency with the default plot function?
Best,
Martin
On 21 Apr 2012, at 08:18 , Marc Schwartz wrote:
> On Apr 21, 2012, at 9:49 AM, Martin Renner wrote:
>
>> When plotting a numerical vector against a factor, 'type="n"' seems to have no affect, e.g.
>>> plot (1:10~factor (1:10), type = "n")
>>
>> looks just like
>>> plot (1:10~factor (1:10))
>>
>> Plotting a numerical against itself works as expected:
>>> plot (1:10, type = "n")
>>
>> I see the same behavior under debian gnu/linux, Mac OS X, and Win7 (all current versions, see below). Is this a bug?
>>
>> Regards,
>> Martin
>
>
>
> This has to do with method dispatch. See ?plot.formula, which is the plot method called you pass a formula, as opposed to passing a vector as in your third example.
>
> In this case, ?plot.factor is called when the 'x' part of the formula (RHS) is a factor. When plot.factor is called, it internally calls ?boxplot and of course, there is no "type = 'n'" for boxplots, hence it is ignored.
>
> Regards,
>
> Marc Schwartz
>
More information about the R-help
mailing list