How do I turn the numeric output of boxplot (with plot=FALSE) into something usable?

前端 未结 3 788
暗喜
暗喜 2020-12-14 04:53

I\'m successfully using the boxplot function to generate... boxplots. Now I need to generate tables containing the stats that boxplot calculates in

3条回答
  •  感动是毒
    2020-12-14 05:39

    If you really want quantiles of your data instead of boxplot numbers, using quantile directly would be my choice (it is far easier to read if you look through what you did later).

    quantile (x, probs = c (0, .25, .5,.75, 1))
    

    quantile itself does not work with groups, but you can combine it with aggregate so it is called for each of the groups given in argument by (needs to be a list, so you can combine here several grouping factors):

    aggregate (chondro$x, by = list (chondro$clusters), 
               FUN = quantile, probs = c (0, .25, .5,.75, 1))
    

    with the result:

       Group.1   x.0%  x.25%  x.50%  x.75% x.100%
    1  matrix -11.55  -6.55   5.45  14.45  22.45
    2  lacuna -11.55  -2.55   4.45  10.45  22.45
    3    cell  -8.55  -1.55  11.45  15.45  20.45
    

    If you really want to have boxplot numbers (e.g. how far the whiskers go), have a look at ? fivenum and ? boxplot.stats.

提交回复
热议问题