仅显示 0-90% 或 0-95% 百分位数 [英] show only 0-90% or 0-95% percentile

查看:28
本文介绍了仅显示 0-90% 或 0-95% 百分位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码和绘图结果,由于一些异常值,x 轴很长.有没有一种简单的方法可以在 R 中仅按 0-90% 或 0-95% 的百分位数过滤 df$foo ,以便我只能绘制正常值?谢谢.

Here is my code and plot results, dues to some outliers, the x-axis is very long. Is there a simple method which I can filter df$foo by only 0-90% or 0-95% percentile in R, so that I can plot only normal values? Thanks.

df <- read.csv('~/Downloads/foo.tsv', sep='\t', header=F, stringsAsFactors=FALSE)
names(df) <- c('a', 'foo', 'goo')
df$foo <- as.numeric(df$foo)
goodValue <- df$foo
summary(goodValue)
hist(goodValue,main="Distribution",xlab="foo",breaks=20)

推荐答案

也许这就是您要找的?

a = c(rnorm(99), 50) #create some data 
quant <- as.numeric(quantile(a, c(0, 0.9))) #get 0 and 0.9 quantile
hist(a[a > quant[1] & a < quant[2]]) #histogram only data within these bounds

这篇关于仅显示 0-90% 或 0-95% 百分位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆