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 dataframe. When I use max, min and mean, I get some values ​​that differ 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 
0        1555    3668    8499    8535  202000   58297 

      

+3


source to share


1 answer


The function summary.default

has an argument digits

:

summary(object, ..., digits = max(3, getOption("digits")-3))

      

Since the default getOptions("digits")

is 7

, you only get numbers 4

. Everything is then rounded off (with a challenge signif()

). You can change as suggested by user20650 .



options(digits=10)

      

Or, if you only want to change for that specific call:

summary(count1, digits = 10)

      

+5


source







All Articles