简体   繁体   English

在R中使用summary()和max,min和mean时的值不同

[英]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.

相关问题 表示数据帧中的行值,不包括R中的最小值和最大值 - mean from row values in a dataframe excluding min and max values in R 删除所有最小值和最大值,然后在R中找到平均值 - Removing ALL min and max values and then finding the mean in R R - 具有预定义的min,max,mean和sd值的随机分布 - R - random distribution with predefined min, max, mean, and sd values 使用 dplyr 跨共享相似名称的列计算按行汇总统计信息,例如平均值、最大值、最小值 - compute row-wise summary statistics such as mean, max, min across columns sharing similar names using dplyr 使用 R 和 tidyverse 在变量的不同级别的比较之间创建最大值和最小值的 dataframe - Create a dataframe of Max and Min Values between comparisons of the different levels of a variable using R and tidyverse 在 R 中使用 ggplot2,如何在各自的点上打印 min、q1、mean、median、q3、max 值? - Using ggplot2 in R, how can I also print min, q1, mean, median, q3, max values on their respective points? 使用 dplyr 分组时如何计算均值、最小值和最大值? - How to calculate mean , min, and max across when grouping using dplyr? 在R中找到一个子集的最大值/平均值/最小值 - Find max/mean/min of the a subset in R R:当 max &lt;= min 时,如何替换(切换)数据帧中一行中的最大值和最小值? - R: How to to replace(switch) the max and min values in a row in a dataframe when max <= min? 在R中运行for循环时设置矩阵单元的最小值和最大值 - Setting min and max values for matrix cells when running a for loop in r
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM