Search code examples
rdata-analysisoutliers

How to remove outliers above a specified value in R?


I am new to R programming. I have a set of two data series. I need to remove outliers that are above a certain value, for example absolute value of 25. Once those values are identified, they need to be removed from both sets. How would I proceed in identifying these values and removing them?

Thanks in advanced!!


Solution

  • If your data is stored in a vector v, then you can do new.v <- v[v <= 25] to store all values that are less than or equal to 25 in a new vector new.v. You can generalize this to new.v <- v[some_condition_to_keep_values]. Note that this works for vectors; it'd be easier to help if you specified what you stored your data in (i.e. a data frame, a matrix, etc).