[英]Different values when using summary() and max, min and mean in R
I am trying to get the max, min and mean of a column in a data frame. 我试图获取数据框中列的最大值,最小值和平均值。 When i use max, min and mean I get some values which are different from the values when I used, summary() 当我使用max,min和mean时,我得到的一些值与我使用时的值不同,summary()
> max(count1,na.rm=TRUE)
[1] 202034
> min(count1,na.rm=TRUE)
[1] 0
> mean(count1,na.rm=TRUE)
[1] 8498.78
> summary(count1,na.rm=TRUE)
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
0 1555 3668 8499 8535 202000 58297
The summary.default
function has a digits
argument: summary.default
函数有一个digits
参数:
summary(object, ..., digits = max(3, getOption("digits")-3))
Since the default getOptions("digits")
is 7
, you get only 4
digits. 由于默认的getOptions("digits")
是7
,因此只能得到4
位数。 Everything after that is rounded (with a call to signif()
). 之后的所有内容都是四舍五入的(调用signif()
)。 You can change as proposed by user20650 setting eg 您可以按照user20650设置的建议进行更改,例如
options(digits=10)
Or if you want the change just for this particular call: 或者,如果您只想为此特定呼叫进行更改:
summary(count1, digits = 10)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.