Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Sum values lower then a threshold with constant

$
0
0

For instance I have a vector:

x <- c(6, 22, 18, 5, 19, 14, 17, 88,30, 0, -1, 2, 3)

How do I check for values lesser than 17 and change the values to value + some const?

something like this:

x[x < 17] <- lesser vaue + 18

expected output:

c(24, 22, 18, 23, 19, 32, 17, 88,30, 18, 17, 20, 21)

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>