Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different values when using summary() and max, min and mean in R

Tags:

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 
like image 952
RpB Avatar asked Dec 01 '25 00:12

RpB


1 Answers

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 e.g.

options(digits=10)

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

summary(count1, digits = 10)
like image 140
Molx Avatar answered Dec 03 '25 13:12

Molx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!