Remove outliers fully from multiple boxplots made with ggplot2 in R and display the boxplots in expanded format

后端 未结 5 1564
孤街浪徒
孤街浪徒 2020-12-08 05:28

I have some data here [in a .txt file] which I read into a data frame df,

df <- read.table(\"data.txt\", header=T,sep=\"\\t\")

I remove

5条回答
  •  有刺的猬
    2020-12-08 06:17

    Another way to exclude outliers is to calculate them then set the y-limit on what you consider an outlier.

    For example, if your upper and lower limits are Q3 + 1.5 IQR and Q1 - 1.5 IQR, then you may use:

    upper.limit <- quantile(x)[4] + 1.5*IQR(x)
    lower.limit <- quantile(x)[2] - 1.5*IQR(x)
    

    Then put limits on the y-axis range:

    ggplot + coord_cartesian(ylim=c(lower.limit, upper.limit))
    

提交回复
热议问题