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?
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) 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
On Sat, 2005-09-24 at 12:00 -0500, Marc Schwartz wrote:> >From 2.0.0 beta ?plot.factor:Ack...That should be 2.2.0 beta. Sorry for the typo. Marc
Dear Gabor, This behaviour makes sense to me, since in the first case the response is quantitative and the explanatory variable a factor (hence, parallel boxplots), while in the second it's vice-versa (hence parallel stacked bars). That is, the primary distinction, I think, isn't the orientation of the axes but the nature of the variables. Regards, John -------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox --------------------------------> -----Original Message----- > From: r-devel-bounces at r-project.org > [mailto:r-devel-bounces at r-project.org] On Behalf Of Gabor Grothendieck > Sent: Saturday, September 24, 2005 10:49 AM > To: R-devel > Subject: [Rd] plot, spineplot, boxplot in R 2.2.0 > > 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? > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
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.
I agree that I was mixing up the two issues. On 9/24/05, John Fox <jfox at mcmaster.ca> wrote:> Dear Gabor, > > This behaviour makes sense to me, since in the first case the response is > quantitative and the explanatory variable a factor (hence, parallel > boxplots), while in the second it's vice-versa (hence parallel stacked > bars). That is, the primary distinction, I think, isn't the orientation of > the axes but the nature of the variables. > > Regards, > John > > -------------------------------- > John Fox > Department of Sociology > McMaster University > Hamilton, Ontario > Canada L8S 4M4 > 905-525-9140x23604 > http://socserv.mcmaster.ca/jfox > -------------------------------- > > > -----Original Message----- > > From: r-devel-bounces at r-project.org > > [mailto:r-devel-bounces at r-project.org] On Behalf Of Gabor Grothendieck > > Sent: Saturday, September 24, 2005 10:49 AM > > To: R-devel > > Subject: [Rd] plot, spineplot, boxplot in R 2.2.0 > > > > 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? > > > > ______________________________________________ > > R-devel at r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > >