谁能解释这段代码的运行方式?

时间:2019-07-13 13:00:29

标签: r

我实际上正在处理一个数据集中的离群值。所以我需要帮助。

我在互联网上找到了这段代码。但是真的不明白它是如何工作的吗?

out_std = function(x){
  m = mean(x)
  s = sd(x)
  lc = m-3*s
  uc= m+3*s
  n = sum(x>uc |  x<lc )
  val = list(num=n,lower_cutoff=lc,upper_cutoff=uc)
  return(val)


lc=out_std(cr_data1$CoapplicantIncome)$lower_cutoff
uc=out_std(cr_data1$CoapplicantIncome)$upper_cutoff
cr_data1$CoapplicantIncome[cr_data1$CoapplicantIncome>uc]=uc
cr_data1$CoapplicantIncome[cr_data1$CoapplicantIncome<lc]=lc

```r

There's nothing wrong in Output part.

0 个答案:

没有答案