从boxplot中提取统计信息

时间:2015-01-27 14:50:45

标签: r

我已经尝试过搜索,但我发现没什么相似之处。 我有一个包含温度的数据集,另一个包含23个地形(分类变量)的数据集。 我绘制了一个温度与地形类型的数据集,在这个图中看到了一个趋势,现在我想从这个图中提取统计数据(即中位数)。

这是我用于绘制boxplot的代码:

boxplot(zone$tm_03 ~ ds3_utm$terr, col='chartreuse3', xlab='Terreno', ylab='Temperatura (°C)', varwidth=T)

这是我发现的箱线图:

Boxplot

我想要做的是从箱图中提取每个类别的中位数值。我想过使用boxplot.stats(),但我没有设法让它工作。

boxplot_stats<-boxplot.stats(zone$tm_01 ~ ds3$terr)
Error in x[floor(d)] + x[ceiling(d)] : 
  non numeric argument transformed in binary operator
Inoltre: Warning messages:
1: In is.na(x) :
is.na() applied to non-(list or vector) of type 'language'
2: In is.na(x) :
is.na() applied to non-(list or vector) of type 'language'
3: In is.na(x) :
is.na() applied to non-(list or vector) of type 'language'

摘要():

> summary(boxplot(zone$tm_03 ~ ds3_utm$terr, col='chartreuse3', xlab='Terreno', ylab='Temperatura (°C)', main='Marzo', varwidth=T))
Errore in summary(boxplot(zone$tm_03 ~ ds3_utm$terr, col = "chartreuse3",  : 
  error in evaluating the argument 'object' in selecting a method for     function 'summary': Errore in eval(expr, envir, enclos) : oggetto "ds3_utm" not found.

任何人都可以帮助我?

提前致谢!

2 个答案:

答案 0 :(得分:5)

来自boxplot帮助:

<强>

列出以下组件:

统计
矩阵,每列包含下部晶须的极端,下部铰链,中位数,上部铰链和上部晶须的极端,用于一组/图。如果所有输入都具有相同的类属性,则此组件也将如此。

<磷>氮
每个组中观察次数的向量。

CONF
矩阵,其中每列包含缺口的下极端和上极端。


    任何超出胡须极端的数据点的值。


    一个与out相同长度的向量,其元素表示异常值属于哪个组。


组的名称向量。

因此,在您的情况下,您可以通过这种方式获得不同类别的中位数:

# 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,]

答案 1 :(得分:4)

尝试以下方法:

> res <-  boxplot(len ~ dose, data = ToothGrowth)
> res
$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"  
相关问题