数据框去除离群点

getwd()
setwd("E:/fanyixian/data")
m1 <- read.table("XXX.txt",header = F)

for (i in 1:nrow(m1)){
motif_1[i,m1[i,58:1057] %in% boxplot.stats(as.numeric(motif_1[i,58:1057]),coef = 4)$out] <- NA
}

kmeans

n <- c(1:nrow(motif_1))
pw <- NULL
for (i in n){
pw[i] <- wilcox.test(as.numeric(motif_1[i,58:207]),as.numeric(motif_1[i,208:1057]),alternative = "greater",na.omit = T)$p.value
}
head(pw)
length(na.omit(pw))
motif_1[1,200:300]
test <- kmeans(motif_1[58:1057],3)$cluster
table(test)
test_result <- which(test == 3)

test1 <- kmeans(motif_1[58:1057],2)
test1 <- test1$cluster
table(test1)

你可能感兴趣的:(数据框去除离群点)