r - 无法获取有关列的基本统计信息
问题描述
我正在运行一些基本代码。我已经清理了数据并想探索一些属性。我运行 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
我只是希望能够从该列中获取统计数据。像最小值,最大值等的东西。
解决方案
我将列更改为 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
谢谢你。
推荐阅读
- c# - AspNet Core with Angular - 我们是否需要创建所有实体的副本?
- android - 这些 ifs 语句会降低性能吗?
- javascript - 阻止代码在第二个 html 块上工作的 Javascript 和 DOM 范围和分配规则的方面是什么?
- xcode - macOS Hardened Runtime 是 OS SDK 的一部分吗?
- javascript - 在 HTML 页面之间传输数据似乎不起作用?
- ios - iOS - 键盘显示时顶部单元格从屏幕上移开
- ruby-on-rails - 在 Rails 嵌套路线上需要帮助
- javascript - 如何使用 post 方法使用 Papaparse 下载 csv 文件?
- python - 不使用**计算指数的迭代函数
- sas - 为什么 proc sql sum 函数返回计数而不是总值?