[R] Boxplot with full x-range
maura.melis at pandora.be
Sun Nov 2 04:32:15 CET 2003
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.
> mydata <- read.table("data.dat")
> 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]
1 1 1 1 1 2
## notice two intervals with zero elements
> boxplot( V2 ~ cats ) ## this draws the boxplot, and just ignores the
> empty intervals
Any help would be appreciated,
(running R1.7.0 on SUSE linux 8.1, AMD Athlon)
Piet van Remortel
More information about the R-help