简体   繁体   中英

R : How to find data only within 1 standard deviation

I have a vector of data and it is normally distributed. I get a clear bell shape from the chart.

Question is how do I get data only belonging to 1sd (68% of data)

Suppose you vector is x , you can use x[abs(x - mean(x)) < sd(x)] to extract data distributed around 1 standard error of the mean.

An alternative method (maybe more preferred) is x[abs(scale(x)) < 1] , where scale(x) gives standardized / normalized x .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM