[R] Shift all values above certain value by 1

Dimitri Liakhovitski dimitri.liakhovitski at gmail.com
Fri Jan 22 17:34:54 CET 2016


Hello!

# I have a data frame x:
x <- data.frame(a = 1:10, b = 2:11, c = 3:12, other = rnorm(10))

# First, I need to change every value 7 in columns a:c to 4
# Then, I need to decrease by 1 all values in columns a:c that are >7

What would be the fastest way of doing it?
Thank you!

-- 
Dimitri Liakhovitski



More information about the R-help mailing list