[R] boxplot via plot command
Ken Knoblauch
ken.knoblauch at inserm.fr
Tue Dec 2 09:39:41 CET 2008
Hi,
Antje <niederlein-rstat <at> yahoo.de> writes:
>
> Hi folks,
>
> I've just discovered that the following code leads to boxplot
> (surprisingly to me).
> Can anybody explain to me why? Is this documented somewhere? I've never
> consider this option before.
>
> x <- rnorm(300)
> l <- c(rep("label1",100), rep("label2",50), rep("label3",150))
>
> df <- data.frame(as.factor(l), x)
> plot(df)
>
> Thank you!
> Antje
>
You can follow this through the various methods. If you look
at plot.data.frame
getAnywhere(plot.data.frame)
You'll see that when the data.frame has only 2 columns, it
calls plot with the first two arguments. Since the first argument
here is a factor, it dispatches to the plot.factor method
getAnywhere(plot.factor)
from which you'll see that under your circumstances it will call
boxplot
HTH,
Ken
More information about the R-help
mailing list