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