Truncation of values in R

3

I need to do a survey to find out how many employees currently earn equal to or above the INSS ceiling ($ 5531.31 in the base reference month). The bases that I have inform the contribution values of the server (11%) and the employer (22%), but not the total remuneration. Therefore an employee who earns more or equal to the tact he contribute with the same value, since the maximum of the calculation basis is said ceiling. The problem is that 0.22 * 5531.31 = 1216.888 , but the bases I own simply ignore the last number. An employee who earns more or equal to the ceiling contributes R$ 1216.88 and R can not detect who wins the most (or equal), because he rounds the multiplication result to 1216.89 . Is there a function that ignores the last few digits without the rounding?

    
asked by anonymous 22.02.2018 / 15:34

1 answer

5

I do not know any R functions that do this, but I have quickly created a function that I believe does what you want:

arredondamento <- function(x){
  floor(100*x)/100
}

I used your example on it and gave the expected result:

> arredondamento(0.22 * 5531.31)
[1] 1216.88

This function can even be applied to vectors:

valores <- c(12.567, 31.333, 0.771)
arredondamento(valores)
[1] 12.56 31.33  0.77
    
22.02.2018 / 16:27