如何使用R中的循环打印离群值?

发布于 2025-02-04 16:19:13 字数 514 浏览 3 评论 0原文

我想使用for-loop创建算法,该算法,返回每个数字(或整数)变量的最低离群值。最低离群值由BoxPlot IE定义:boxplot.stats(dataframe [[n]])$ out。 如果在该数字/整数列中不存在异常值,则打印第二个字符串。

for(i in df){
  lowest <- ifelse(is.numeric(i), min(boxplot.stats(i)$out), "not numeric/integer")
  print(ifelse(lowest != "Inf", lowest, "No outliers"))
}

我已经对此进行了管理,但我得到了以下警告:

Warning message:
In min(boxplot.stats(i)$out) :
  no non-missing arguments to min; returning Inf

I want to create an algorithm using a for-loop that returns the lowest outlier for each numeric (or integer) variable. Where the lowest outlier is defined by a boxplot i.e. : boxplot.stats(dataframe[[n]])$out.
And print a second string if no outliers exist within that numeric/integer column.

for(i in df){
  lowest <- ifelse(is.numeric(i), min(boxplot.stats(i)$out), "not numeric/integer")
  print(ifelse(lowest != "Inf", lowest, "No outliers"))
}

I have managed with this but I get the following warning:

Warning message:
In min(boxplot.stats(i)$out) :
  no non-missing arguments to min; returning Inf

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文