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 Martin Renner Post-doctoral Fellow phone: 907-226 4672 University of Washington or: 907-235 0728 School of Aquatic and Fishery Sciences Seattle, USA> sessionInfo()R version 2.15.0 (2012-03-30) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=C LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base
On 21.04.2012 16:49, 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))This plots 10 boxplots and the data are passed from plot.formula. plot.formula does not accept a "type" argument. plot.default() does, but that is not used once your use a formula. Uwe Ligges> > 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 > > > > Martin Renner > Post-doctoral Fellow phone: 907-226 4672 > University of Washington or: 907-235 0728 > School of Aquatic and Fishery Sciences Seattle, USA > > > >> sessionInfo() > R version 2.15.0 (2012-03-30) > Platform: x86_64-unknown-linux-gnu (64-bit) > > locale: > [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C > [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 > [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 > [7] LC_PAPER=C LC_NAME=C > [9] LC_ADDRESS=C LC_TELEPHONE=C > [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C > > attached base packages: > [1] stats graphics grDevices utils datasets methods base > ______________________________________________ > R-help at r-project.org mailing list > 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.
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, > MartinThis 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