Extract statistics from boxplot

前端 未结 2 1139
余生分开走
余生分开走 2020-12-21 14:48

I\'ve already tried searching but I\'ve found nothing similar. I have a dataset containing temperatures, and another dataset containing 23 tipes of terrain (categorical vari

相关标签:
2条回答
  • 2020-12-21 15:05

    Try the following:

    res <-  boxplot(len ~ dose, data = ToothGrowth)
    res
    

    giving:

    $stats
          [,1]  [,2]  [,3]
    [1,]  4.20 13.60 18.50
    [2,]  7.15 16.00 23.45
    [3,]  9.85 19.25 25.95
    [4,] 13.00 23.45 28.35
    [5,] 21.50 27.30 33.90
    
    $n
    [1] 20 20 20
    
    $conf
              [,1]     [,2]     [,3]
    [1,]  7.783202 16.61792 24.21884
    [2,] 11.916798 21.88208 27.68116
    
    $out
    numeric(0)
    
    $group
    numeric(0)
    
    $names
    [1] "0.5" "1"   "2"  
    
    0 讨论(0)
  • 2020-12-21 15:07

    From boxplot help:

    Value

    List with the following components:

    stats
    a matrix, each column contains the extreme of the lower whisker, the lower hinge, the median, the upper hinge and the extreme of the upper whisker for one group/plot. If all the inputs have the same class attribute, so will this component.

    n
    a vector with the number of observations in each group.

    conf
    a matrix where each column contains the lower and upper extremes of the notch.

    out
    the values of any data points which lie beyond the extremes of the whiskers.

    group
    a vector of the same length as out whose elements indicate to which group the outlier belongs.

    names
    a vector of names for the groups.

    So in your case, you can get the medians of the different categories this way:

    # drawing the boxplots and assigning the results to an object
    bp<-boxplot(zone$tm_03 ~ ds3_utm$terr, col='chartreuse3', xlab='Terreno', ylab='Temperatura (°C)', varwidth=T)
    # get the different medians, which are on the 3rd row of the stats element
    bp$stats[3,]
    
    0 讨论(0)
提交回复
热议问题