无法获得有关列的基本统计信息

时间:2019-01-04 21:47:49

标签: r

我正在运行一些基本代码。我已经清理了数据并想探索一些属性。我运行describe(census $ Age)代码,但出现以下错误     x-mx错误:二进制运算符的非数字参数。

这是什么意思,请问如何解决?

这是我正在从事的项目。

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

我只想能够从此列获取统计数据。诸如最小,最大等之类的

1 个答案:

答案 0 :(得分:0)

我将列更改为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 

谢谢。