Skip to content

Commit 6ca9ee7

Browse files
author
smeyer
committed
add basic plot(<factor>) example
git-svn-id: https://svn.r-project.org/R/trunk@87423 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 01c98e0 commit 6ca9ee7

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

src/library/graphics/man/plot.factor.Rd

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
% File src/library/graphics/man/plotfactor.Rd
22
% Part of the R package, https://www.R-project.org
3-
% Copyright 1995-2009 R Core Team
3+
% Copyright 1995-2024 R Core Team
44
% Distributed under GPL 2 or later
55

66
\name{plot.factor}
7+
\alias{plot.factor}
78
\title{Plotting Factor Variables}
89
\usage{
9-
\method{plot}{factor}(x, y, legend.text = NULL, \dots)
10+
\method{plot}{factor}(x, y, legend.text = NULL, ...)
1011
}
11-
\alias{plot.factor}
1212
\arguments{
1313
\item{x, y}{numeric or factor. \code{y} may be missing.}
1414
\item{legend.text}{character vector for annotation of y axis in the
@@ -17,18 +17,18 @@
1717
\item{\dots}{Further arguments to \code{\link{barplot}},
1818
\code{\link{boxplot}}, \code{\link{spineplot}} or
1919
\code{\link{plot}} as appropriate. All of these accept
20-
\link{graphical parameters} (see \code{\link{par}}) and
20+
\link{graphical parameters} (see \code{\link{par}}),
2121
annotation arguments passed
22-
to \code{\link{title}} and \code{axes = FALSE}. None accept \code{type}.
22+
to \code{\link{title}}, and \code{axes = FALSE}. None accept \code{type}.
2323
}
2424
}
2525
\description{
2626
This method is used for
2727
\code{\link{factor}} arguments of the \emph{generic}
2828
\code{\link{plot}} function,
29-
possibly called from the formula method (see the Examples).
29+
possibly called from the formula method.
3030

31-
If \code{y} is missing \code{\link{barplot}} is produced.
31+
If \code{y} is missing a \code{\link{barplot}} is produced.
3232
For numeric \code{y} a \code{\link{boxplot}} is used, and for a factor
3333
\code{y} a \code{\link{spineplot}} is shown. For any other type of
3434
\code{y} the next \code{plot} method is called, normally
@@ -40,9 +40,12 @@
4040
}
4141
\examples{
4242
require(grDevices)
43-
% this does not call plot.factor!
44-
% plot(PlantGrowth) # -> plot.data.frame
45-
plot(weight ~ group, data = PlantGrowth) # numeric vector ~ factor
43+
44+
plot(state.region)
45+
46+
## called from the formula method
47+
plot(~ group, data = PlantGrowth)
48+
plot(weight ~ group, data = PlantGrowth) # numeric ~ factor
4649
plot(cut(weight, 2) ~ group, data = PlantGrowth) # factor ~ factor
4750
## passing "..." to spineplot() eventually:
4851
plot(cut(weight, 3) ~ group, data = PlantGrowth,

tests/Examples/graphics-Ex.Rout.save

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,12 @@ Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’
21742174
> ### ** Examples
21752175
>
21762176
> require(grDevices)
2177-
> plot(weight ~ group, data = PlantGrowth) # numeric vector ~ factor
2177+
>
2178+
> plot(state.region)
2179+
>
2180+
> ## called from the formula method
2181+
> plot(~ group, data = PlantGrowth)
2182+
> plot(weight ~ group, data = PlantGrowth) # numeric ~ factor
21782183
> plot(cut(weight, 2) ~ group, data = PlantGrowth) # factor ~ factor
21792184
> ## passing "..." to spineplot() eventually:
21802185
> plot(cut(weight, 3) ~ group, data = PlantGrowth,

0 commit comments

Comments
 (0)