0

我想以这种方式转换以下数字我尝试使用所有可能的方法但我无法获得我期望的值

value        round off value
0.0 - 4.9         0
5.0 - 5.9         6
6.0 - 6.9         7
7.0 - 7.9         8
8.0 - 8.9         9
9.0 - 10.0        10

上表供参考

expected output  eg :- roundup(5.0) = 6  ,roundup(6.9)=7
4

1 回答 1

1

你可以试试:

roundup<-function(x) c(0,6:10)[findInterval(x,c(0,5:9))]
roundup(c(5,6.9))
#[1] 6 7
于 2017-02-19T07:14:06.643 回答