我有以下R代码:
library(ggplot2)
data(diamonds)
by(diamonds$price, diamonds$cut, summary)
by(diamonds$price, diamonds$cut, max)
这给了我:
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
我不明白为什么这两个表的最大值不同。最大值不应该一样吗?
最佳答案
这是数字参数?summary
by(diamonds$price, diamonds$cut, function(x) summary(x, digits = 10 ))`
给最大