jak123
June 24, 2021, 9:39am
1
Hi R community!
have the dataframa called df a column named MD within this frame. I want to print every df$MD > 5, so that I can see the outliers. (MD = mahalanobis distance)
Code:
for (i in 1:length(df$MD)){
if (df$MD[1:100] > 5){
print(df$MD[1:100]) # value with name
}
}
Error:
There were 50 or more warnings (use warnings() to see the first 50)
FJCC
June 24, 2021, 12:26pm
2
I suggest you filter the original data frame to keep only the rows with MD > 5. In base R you can do
GT5 <- df[df$MD > 5, ]
With the dplyr package, you can do
library(dplyr)
GT5 <- filter(df, MD > 5)
You can then print the MD column of GT5 or plot its values
system
Closed
July 1, 2021, 12:27pm
3
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.