I worked out something that is running ok. If there is another way please let me know!

```
zf <- df2
id_list <- list()
for(i in 1:11) {
v <- paste("x",i,sep="")
print(v)
data_outliers <- subset(zf, abs(df3[[v]]) > zstat)
numOutliers <- dim(data_outliers)[1]
cat("Number of outliers is ", numOutliers, "\n")
cat("outlier ids are","\n")
print(data_outliers$id)
id_list[[i]] = unlist(data_outliers$id)
data_nooutliers <- subset(zf, abs(df3[[v]])< zstat)
numNooutliers <- dim(data_nooutliers)[1]
cat("\n","Number of nooutliers is ", numNooutliers, "\n")
cat("first 25 nooutlier ids are","\n")
print(head(data_nooutliers$id,25))
cat("\n","numOutliers+numNooutliers=",numOutliers+numNooutliers,"\n","\n")
}
# a is a vector of unique id values that are outliers
# outlier.df is an extraction of df2 containing all outlier rows
a <- unique(unlist(id_list))
class(a) #integer vector
head(a,10) # 4 46 57 114 198 206 207 210 213 242 ...
length(a) # 2173
outlier.df <- df2[a,]
dim(outlier.df) # 2173 x 17
names(outlier.df)
head(outlier.df,10) #id column: 4 46 57 114 198 206 207 210 213 242
# keep.df is a dataframe consisting of ids not in a
# keep.df is a dataframe where all predictors x1:x11 are not outliers
keep.df <- subset(df2,!id %in% a)
class(keep.df) #dataframe
dim(keep.df) # 4324 x 17
head(keep.df,10) # id column: 7 10 11 12 17 19 21 22 24 25
# in summary, we have outlier.df and keep.df dataframes
# df7 is a dataframe where predictors x1:x11 have no outliers
df7 <- keep.df
```