在R ona数据帧中使用boxplot.stats删除异常值

时间:2018-06-09 07:55:27

标签: r boxplot outliers iqr

我试图在数据帧上使用IQR(boxplot.stats)删除异常值。但我得到以下错误。异常值检查应该在每个变量中发生,如果一个变量是异常值,则删除整行(所有变量)。

'data.frame':   214 obs. of  7 variables:
 $ V2: num  0.115 0.112 0.106 0.104 0.108 0.116 0.127 0.117 0.115 0.114 ...
 $ V3: num  0.144 0.175 0.179 0.171 0.167 0.174 0.152 0.178 0.159 0.178 ...
 $ V4: num  0.152 0.203 0.221 0.216 0.22 0.205 0.214 0.182 0.211 0.195 ...
 $ V5: num  0.191 0.171 0.161 0.172 0.167 0.171 0.156 0.174 0.173 0.171 ...
 $ V6: num  0.173 0.165 0.156 0.164 0.167 0.163 0.144 0.162 0.165 0.164 ...
 $ V7: num  0.146 0.116 0.116 0.116 0.113 0.116 0.146 0.126 0.117 0.121 ...
 $ V8: num  0.078 0.057 0.061 0.056 0.057 0.054 0.061 0.061 0.06 0.059 ...
 > Outlier = boxplot.stats(SizePro)
 Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = 
 decreasing)) : 
 undefined columns selected

1 个答案:

答案 0 :(得分:0)

apply(df, 2, boxplot.stats) 能够同时计算一个箱线图,因此您需要将其循环到数据帧上:

> library(RSelenium)
> rD = rsDriver()
checking Selenium Server versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking chromedriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking geckodriver versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
checking phantomjs versions:
BEGIN: PREDOWNLOAD
BEGIN: DOWNLOAD
BEGIN: POSTDOWNLOAD
[1] "Connecting to remote server"

Selenium message:unknown error: DevToolsActivePort file doesn't exist
  (Driver info: chromedriver=2.40.565383 (76257d1ab79276b2d53ee976b2c3e3b9f335cde7),platform=Linux 4.4.0-127-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.04 seconds
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z'
System info: host: 'ubuntu-s-2vcpu-4gb-blr1-01', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-127-generic', java.version: '1.8.0_171'
Driver info: driver.version: unknown

Could not open chrome browser.
Client error message:
     Summary: UnknownError
     Detail: An unknown server-side error occurred while processing the command.
     Further Details: run errorDetails method
Check server log for further details.