[Rd] plot, spineplot, boxplot in R 2.2.0

Gabor Grothendieck ggrothendieck at gmail.com
Sat Sep 24 19:40:15 CEST 2005


On 9/24/05, Marc Schwartz <MSchwartz at mn.rr.com> wrote:
> On Sat, 2005-09-24 at 11:48 -0400, Gabor Grothendieck wrote:
> > I noticed, what seened to me, to be odd.  These produce
> > a boxplot in the first case and a spineplot in the second
> > case in R .2.2.0:
> >
> > plot(Sepal.Length ~ Species, iris)
> > plot(Species ~ Sepal.Length, iris)
> >
> > What if one wants to exchange axes?  Does the fact that
> > this seemingly innocuous change result in completely
> > different graphics make sense?  Is it desirable?
>
> Gabor,
>
> Did you try:
>
> plot(Sepal.Length ~ Species, iris, horizontal = TRUE)

I had tried horiz= which did not have any effect but I should
have written it all out since it comes after a ... .  In any
case it works as you have shown but not if I interchange
the variables.

>
> This will rotate the boxplot by 90 degrees, as expected.
>
> The plot method is dispatched based upon (from ?plot.formula):
>
> If y is an object (i.e. has a class attribute) then plot.formula looks
> for a plot method for that class first. Otherwise, the class of x will
> determine the type of the plot. For factors this will be a parallel
> boxplot, and argument horizontal = TRUE can be used (see boxplot).
>
>
> Since there is no plot.numeric(), plot.factor() will be used.
>
> This is unchanged from 2.1.1.
>
> What is changed is the plot that is created in your second case. In
> 2.1.1, this was a barplot, rather than a spineplot. From
> 2.1.1 ?plot.factor:
>
> This functions implements a "scatterplot" method for factor arguments of
> the generic plot function. Actually, boxplot or barplot are used when
> appropriate.
>
>
> >From 2.0.0 beta ?plot.factor:
>
> This functions implements a "scatterplot" method for factor arguments of
> the generic plot function. Actually, boxplot is used when y is numeric
> and a spineplot when y is a factor. For a single factor x (i.e., with y
> missing) a simple barplot is produced.
>
>
>
> HTH,
>
> Marc Schwartz
>
>
>

OK. Thanks.



More information about the R-devel mailing list