简体   繁体   中英

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(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(object, ..., digits = max(3, getOption("digits")-3))

Since the default getOptions("digits") is 7 , you get only 4 digits. Everything after that is rounded (with a call to signif() ). You can change as proposed by user20650 setting eg

options(digits=10)

Or if you want the change just for this particular call:

summary(count1, digits = 10)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM