On Sat, 2006-04-15 at 19:26 +0200, Bernd Dittmann wrote:> Dear useRs,
>
> how can I construct a box&whisker plot based on the vector
"fivenum"?
>
> The challenge I face is as follow: I have a table such as
>
> x | fivenum
> ---------------
> ... | (.....)
> ... | (.....)
>
> and so forth....
>
>
> For each observation x I have generated a vector containing the fivenum
> estimates.
>
> The first challenge is to group my fivenum vectors into groups based on
> a selection criterion of x, say for 0 < x < 6, all fivenum vectors
would
> be collected in that group.
>
> Once all my fivenum vectors are in their respective groups, I wish to
> generate a b&w plot for each group.
>
>
> How could I possibly do that? Also, what would be the most convenient
> approach.
>
> Looking forward to your suggestions.
>
> Many thanks in advance!
>
> Sincerely,
>
> Bernd Dittmann
I'm not entirely clear what 'x' is. Is it the source vectors upon
which
the fivenum values have been generated or is it simply an index value of
sorts.
In either case, note the following:
1. bxp() will create a boxplot based upon passing it the results of a
summary type function. Typically this is boxplot.stats(). You might want
to review both programs and consider that they may better fit your
requirements. ?bxp and ?boxplot.stats for more information.
fivenum() does not identify the typical 'outliers' that are drawn in the
boxplot, where as boxplot.stats() does and results in an object better
used by bxp() directly.
2. For grouping, you can consider using split(), perhaps after using
cut() on your 'x' to define a factor based upon specific break points on
'x'. This presumes that 'x' is a scalar index value.
split() will result in grouping your results in a list. You can then use
lapply() on the list components. See ?split, ?cut and ?lapply.
If that is not helpful, please supply some sample data so that we can
help further by seeing what you are actually dealing with. The dput()
function can be helpful here. See ?dput.
HTH,
Marc Schwartz