首页 > 解决方案 > 无法获取有关列的基本统计信息

问题描述

我正在运行一些基本代码。我已经清理了数据并想探索一些属性。我运行 describe(census$Age) 代码,但出现以下错误 Error in x - mx : non-numeric argument to binary operator。

这是什么意思,我该如何解决?

这是我正在做的一个项目。

Error in x - mx : non-numeric argument to binary operator
In addition: Warning messages:
1: In mean.default(x, na.rm = na.rm) :
  argument is not numeric or logical: returning NA
2: In var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = 
na.rm) :
  NAs introduced by coercion
3: In mean.default(sort(x, partial = half + 0L:1L)[half + 0L:1L]) :
  argument is not numeric or logical: returning NA
4: In mean.default(x, na.rm = na.rm, trim = trim) :
  argument is not numeric or logical: returning NA
5: In var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = 
na.rm) :
  NAs introduced by coercion
6: In mean.default(x) : argument is not numeric or logical: returning NA

我只是希望能够从该列中获取统计数据。像最小值,最大值等的东西。

标签: r

解决方案


我将列更改为 as.numeric,然后安装打包的 pastecs。

 install.packages("pastecs")
 library(pastecs)
 census1$Age<-as.numeric(census1$Age)
 stat.desc(census1$Age)
 can also use summary(census1$Age) but that does not give you standard deviation 

谢谢你。


推荐阅读