I\'d like to replace all values in my relatively large R dataset which take values above the 95th and below the 5th percentile, with those percentile values
I used this code to get what you need:
qn = quantile(df$value, c(0.05, 0.95), na.rm = TRUE) df = within(df, { value = ifelse(value < qn[1], qn[1], value) value = ifelse(value > qn[2], qn[2], value)})
where df is your data.frame, and value the column that contains your data.
df
value