[R] Boxplot with full x-range
kjetil@entelnet.bo
kjetil at entelnet.bo
Sun Nov 2 05:39:34 CET 2003
On 2 Nov 2003 at 4:32, Maura Melis wrote:
?boxplot
look at the argument at=, where you can give the position for each of
the boxes.
(with this data you could also be interested in
?coplot)
Kjetil Halvorse
> Hi all,
>
> I'm new to R, and have the following problem:
>
> I wish to draw a boxplot of simple data in two columns. The x-axis
> (taken from first column) is grouped to intervals (using 'cut').
> These intervals serve as x-value to the boxplot, and the data from the
> second column are the y-values.
>
> The problem is that I want to give an impression of the trend of the data
> in the x-range. However, when an interval on the x-axis contains no
> y-data, no box is drawn, and the plot becomes 'narrower' in the
> x-direction, giving a wrong impression of the trend of the y-value.
>
> What I want is that no box is drawn for emtpy interval, but some X-space
> is kept open. In other words, I want ALL interval to be drawn, including
> the empty ones.
>
> Example scenario:
>
> data.dat:
> 0.1 5
> 0.15 4.5
> 0.3 2
> 0.31 2.2
> 0.5 1
> 0.55 1.1
> 0.56 1.15
> 0.7 0.5
> 0.9 0.1
>
>
> > mydata <- read.table("data.dat")
> > attach(mydata)
> > cats = cut( V1, breaks=(0:10)*.1)
> > symmary( cats )
>
> (0,0.1] (0.1,0.2] (0.2,0.3] (0.3,0.4] (0.4,0.5] (0.5,0.6] (0.6,0.7]
> (0.7,0.8]
> 1 1 1 1 1 2
> 1 0
> (0.8,0.9] (0.9,1]
> 1 0
>
> ## notice two intervals with zero elements
>
> > boxplot( V2 ~ cats ) ## this draws the boxplot, and just ignores the
> > empty intervals
>
> Any help would be appreciated,
>
> tnx
>
> Piet
>
>
> (running R1.7.0 on SUSE linux 8.1, AMD Athlon)
>
>
> ---
> Piet van Remortel
> Belgium
> pvremortATvub.ac.be
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list