【问题标题】:Can't get basic stats about a column无法获取有关列的基本统计信息
【发布时间】:2019-01-06 05:19:52
【问题描述】:

我正在运行一些基本代码。我已经清理了数据并想探索一些属性。我运行 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

我只是希望能够从此列中获取统计数据。诸如最小值、最大值等的东西。

【问题讨论】:

    标签: r


    【解决方案1】:

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

    谢谢。

    【讨论】:

    • 这是否意味着回答您的问题(这是完全有效的)?如果没有,请编辑您的问题并在此处删除此问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-23
    • 2011-08-20
    • 2018-05-02
    • 1970-01-01
    • 1970-01-01
    • 2012-06-18
    相关资源
    最近更新 更多