Hi,
I have a data frame with three columns and 40 rows. The 1st two columns contain a value range from -1 to 1, and the 3rd column contains the sum of the two columns. Therefore, I would like to change values closer to zero, such as o.3,0.2,0.1,-0.1,-0.2,-0.3 in the 3rd columns to zero, and keep the rest as it was.
library(dplyr)
set.seed(2)
D = data.frame(from = runif(40, -1,1), to = runif(40,-1,1)) %>% dplyr::mutate(weight = from + to)
Appreciate your help.
Thank you! Best, ADR