3

I have the following R code:

 library(ggplot2)
 data(diamonds)
 by(diamonds$price, diamonds$cut, summary)
 by(diamonds$price, diamonds$cut, max)

This gives me:

diamonds$cut: Fair
Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
337    2050    3282    4359    5206   18570 
---------------------------------------------- 
  diamonds$cut: Good
Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
327    1145    3050    3929    5028   18790 
---------------------------------------------- 
  diamonds$cut: Very Good
Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
336     912    2648    3982    5373   18820 
---------------------------------------------- 
  diamonds$cut: Premium
Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
326    1046    3185    4584    6296   18820 
---------------------------------------------- 
  diamonds$cut: Ideal
Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
326     878    1810    3458    4678   18810 

diamonds$cut: Fair
[1] 18574
---------------------------------------------- 
  diamonds$cut: Good
[1] 18788
---------------------------------------------- 
  diamonds$cut: Very Good
[1] 18818
---------------------------------------------- 
  diamonds$cut: Premium
[1] 18823
---------------------------------------------- 
  diamonds$cut: Ideal
[1] 18806

I don't understand why the maxima in these two tables differ. Shouldn't the maxima be the same?

Ohumeronen
  • 1,769
  • 2
  • 14
  • 28

1 Answers1

5

it's the digits argument ?summary

by(diamonds$price, diamonds$cut, function(x) summary(x, digits = 10   ))`

give same as max

s.brunel
  • 1,003
  • 10
  • 24