Search
 
SCRIPT & CODE EXAMPLE
 

R

outlier tagging boxplot r

library(dplyr)
library(ggplot2)

is_outlier <- function(x) {
  return(x < quantile(x, 0.25) - 1.5 * IQR(x) | x > quantile(x, 0.75) + 1.5 * IQR(x))
}

mtcars %>%
  group_by(cyl) %>%
  mutate(outlier = ifelse(is_outlier(drat), drat, as.numeric(NA))) %>%
  ggplot(., aes(x = factor(cyl), y = drat)) +
    geom_boxplot() +
    geom_text(aes(label = outlier), na.rm = TRUE, hjust = -0.3)
Comment

PREVIOUS NEXT
Code Example
R :: convert list to dataframe r 
R :: r list files in directory 
R :: paste no space r 
R :: remove null element from list r 
R :: remove elements from character vector in r 
R :: R p value star 
R :: how to append in a list in R 
R :: defulat function values R 
R :: how to convert all columns of a dataframe into factors in r 
R :: r replace blank string with na 
R :: r combine strings 
R :: rename columns based on a variable in r 
R :: r concatenate data frame 
R :: how to change the index of a dataframe in r 
R :: Getting rid of row names in R 
R :: convert a matrix to a vector in r 
R :: r replace space with 
R :: repeat sample in r 
R :: extract pc1 and pc2 in r 
R :: r count list 
R :: bar plot r 
R :: extract hyperlinks in r 
R :: Use regex to extract row in R (solution 1) 
R :: Edit axis labels R 
R :: base R change axis line width 
R :: how to add in R dictionary 
Rust :: rust create folder 
Rust :: making a web server in rust 
Rust :: rust string slice 
Rust :: rust cube root 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =