creating a new column based on multiple conditional statements in r

You can use plyrs round_any function

df$value1 <- plyr::round_any(df$value, 0.1, ceiling)
df
#        value value1
#1  0.59465953    0.6
#2  0.10581043    0.2
#3  0.48806113    0.5
#4  0.04106798    0.1
#5  0.24026985    0.3
#6  0.08468660    0.1
#7  0.11598592    0.2
#8  0.50481103    0.6
#9  0.43194839    0.5
#10 0.16032725    0.2
#11 0.29700099    0.3
#12 0.04986834    0.1
#13 0.21233054    0.3
#14 0.58152528    0.6
#...

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top