I’m working on a large data and I’m trying to trim the extreme values like the ones < 0 and > 8 how can I do that in R?
Atrim = c(0,8)
CodePudding user response:
0:8
trim(0:8)
trim(0:8, trim=0.8)
CodePudding user response:
You were not clear how to handle the outliers. Should they be elimnated or changed to NAs? Here is a simple example that deletes the extreme values:
set.seed(42) # for reproducibility
x <- rnorm(50, 4, 2.5) # Generate 50 random values
y <- x[x >= 0 & x <= 8] # Remove outliers
length(y)
# [1] 41 # Nine values were removed.