Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace values in a numerical range

Tags:

r

Hi guys a very simple question. How can I replace values < 1.5 and the values > -1.5 with 0 in a data.frame? Should be "pipe" the best solution?

Thanks a lot!

E.

like image 271
Elb Avatar asked Jan 21 '26 18:01

Elb


1 Answers

It’s as simple as this:

data[data > -1.5 & data < 1.5] <- 0
like image 67
Konrad Rudolph Avatar answered Jan 23 '26 08:01

Konrad Rudolph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!